From 4425b2326bdf9098eb05d4427f62398e9de015fc Mon Sep 17 00:00:00 2001 From: OnlyMares Date: Fri, 3 Mar 2023 18:48:30 -0600 Subject: [PATCH] Spawning! the other half of the cupcake spawn code --- .godot/editor/create_recent.Node | 1 + .godot/editor/editor_layout.cfg | 2 +- .godot/editor/filesystem_update4 | 1 + ...lding-bdbf2ba254a2078c85b005689e1549ff.cfg | 2 +- .godot/editor/project_metadata.cfg | 5 ++- .godot/editor/recent_dirs | 2 + .godot/editor/script_editor_cache.cfg | 18 ++++----- .godot/uid_cache.bin | Bin 426 -> 468 bytes Scenes/Cupcakes/cupcake.tscn | 1 + Scenes/UI/ingame_ui.tscn | 9 +++++ Scenes/game_world.tscn | 11 +++++- Scripts/Cupcakes/cupcake.gd | 5 ++- Scripts/game_world.gd | 37 +++++++++++++----- Scripts/horse.gd | 9 +++++ export_presets.cfg | 0 15 files changed, 76 insertions(+), 27 deletions(-) create mode 100644 Scenes/UI/ingame_ui.tscn create mode 100644 export_presets.cfg diff --git a/.godot/editor/create_recent.Node b/.godot/editor/create_recent.Node index 5a17d98..c3f31cd 100644 --- a/.godot/editor/create_recent.Node +++ b/.godot/editor/create_recent.Node @@ -1,3 +1,4 @@ +Node2D Sprite2D CollisionShape2D Area2D diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg index ad16558..75d9d4e 100644 --- a/.godot/editor/editor_layout.cfg +++ b/.godot/editor/editor_layout.cfg @@ -18,7 +18,7 @@ dock_5="Inspector,Node,History,Commit (14)" [EditorNode] -open_scenes=["res://Scenes/game_world.tscn", "res://Scenes/horse.tscn", "res://Scenes/Cupcakes/cupcake.tscn", "res://Scenes/Locations/yard.tscn"] +open_scenes=["res://Scenes/game_world.tscn", "res://Scenes/horse.tscn", "res://Scenes/Cupcakes/cupcake.tscn", "res://Scenes/Locations/yard.tscn", "res://Scenes/UI/ingame_ui.tscn"] [ScriptEditor] diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index de26c84..8fac1e5 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -7,3 +7,4 @@ res://Scripts/horse.gd res://Scripts/Cupcakes/cupcake.gd res://Scenes/Locations/yard.tscn res://README.md +res://Scenes/UI/ingame_ui.tscn diff --git a/.godot/editor/game_world.tscn-folding-bdbf2ba254a2078c85b005689e1549ff.cfg b/.godot/editor/game_world.tscn-folding-bdbf2ba254a2078c85b005689e1549ff.cfg index c958f56..9847aa0 100644 --- a/.godot/editor/game_world.tscn-folding-bdbf2ba254a2078c85b005689e1549ff.cfg +++ b/.godot/editor/game_world.tscn-folding-bdbf2ba254a2078c85b005689e1549ff.cfg @@ -1,5 +1,5 @@ [folding] -node_unfolds=[NodePath("."), PackedStringArray("Transform", "Material", "Texture", "Ordering", "Visibility", "Editor Description", "Process", "ccVanilla")] +node_unfolds=[NodePath("."), PackedStringArray("Transform", "Material", "Texture", "Ordering", "Visibility", "Editor Description", "Process", "ccVanilla"), NodePath("PlayArea"), PackedStringArray("Input", "Collision")] resource_unfolds=["res://Scenes/game_world.tscn::RectangleShape2D_sh03e", PackedStringArray()] nodes_folded=[] diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 2ca7182..57f3346 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -10,9 +10,10 @@ run_reload_scripts=true [dialog_bounds] -project_settings=Rect2(814, 476, 1120, 920) +project_settings=Rect2(814, 506, 1120, 920) editor_settings=Rect2(830, 460, 900, 700) search_help=Rect2(640, 390, 1280, 720) +export=Rect2(830, 430, 900, 700) [color_picker] @@ -20,7 +21,7 @@ recent_presets=PackedColorArray(0, 0, 0, 1, 0.2, 0.0156863, 0.286275, 0.431373, [recent_files] -scenes=["res://Scenes/Locations/yard.tscn", "res://Scenes/Locations/y.tscn", "res://Scenes/Locations/Yard.tscn", "res://Scenes/Cupcakes/cupcake.tscn", "res://Scenes/horse.tscn", "res://Scenes/game_world.tscn", "res://Scenes/cupcake.tscn"] +scenes=["res://Scenes/UI/ingame_ui.tscn", "res://Scenes/Locations/yard.tscn", "res://Scenes/Locations/y.tscn", "res://Scenes/Locations/Yard.tscn", "res://Scenes/Cupcakes/cupcake.tscn", "res://Scenes/horse.tscn", "res://Scenes/game_world.tscn", "res://Scenes/cupcake.tscn"] scripts=["res://README.md", "res://Scripts/Cupcakes/cupcake.gd", "res://Scripts/Cupcake Spawn Timer.gd", "Node", "res://Scripts/game_world.gd", "res://Scripts/horse.gd"] [script_setup] diff --git a/.godot/editor/recent_dirs b/.godot/editor/recent_dirs index 5470b8f..db05ef9 100644 --- a/.godot/editor/recent_dirs +++ b/.godot/editor/recent_dirs @@ -1,3 +1,5 @@ +res://Scenes/UI +/home/shobie/CupcakeRevolution1 res://Scenes/Locations res://Art/Locations res://Scripts/Cupcakes diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index 87ec740..f87b85c 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -3,7 +3,7 @@ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 10, +"column": 0, "folded_lines": Array[int]([]), "h_scroll_position": 0, "row": 5, @@ -17,16 +17,12 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 1, +"column": 0, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 34, -"scroll_position": 5.0, -"selection": true, -"selection_from_column": 1, -"selection_from_line": 34, -"selection_to_column": 17, -"selection_to_line": 34, +"row": 50, +"scroll_position": 4.0, +"selection": false, "syntax_highlighter": "GDScript" } @@ -49,10 +45,10 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 1, +"column": 14, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 10, +"row": 14, "scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" diff --git a/.godot/uid_cache.bin b/.godot/uid_cache.bin index b71c2e8867236cbc64efc0acf9cc9d95084c721b..ded6b41682272e20bb36d1e75759cbf0f951ee31 100644 GIT binary patch delta 53 zcmZ3*e1(~jdn4mYMy621Tc delta 10 Rcmcb@yo#BTYa`=IMgS5d0_*?) diff --git a/Scenes/Cupcakes/cupcake.tscn b/Scenes/Cupcakes/cupcake.tscn index 1989404..8b34422 100644 --- a/Scenes/Cupcakes/cupcake.tscn +++ b/Scenes/Cupcakes/cupcake.tscn @@ -7,6 +7,7 @@ radius = 16.0 [node name="Cupcake" type="RigidBody2D"] +collision_layer = 2 gravity_scale = 0.0 linear_damp = 6.0 script = ExtResource("1_2fcqt") diff --git a/Scenes/UI/ingame_ui.tscn b/Scenes/UI/ingame_ui.tscn new file mode 100644 index 0000000..a0c628c --- /dev/null +++ b/Scenes/UI/ingame_ui.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://c4dtrk2kooa6q"] + +[node name="IngameUI" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/Scenes/game_world.tscn b/Scenes/game_world.tscn index a50dd1c..46bbccf 100644 --- a/Scenes/game_world.tscn +++ b/Scenes/game_world.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://dlypem0porccr"] +[gd_scene load_steps=5 format=3 uid="uid://dlypem0porccr"] [ext_resource type="Script" path="res://Scripts/game_world.gd" id="1_c2sx0"] [ext_resource type="Script" path="res://Scripts/Cupcake Spawn Timer.gd" id="2_bjylp"] +[ext_resource type="PackedScene" uid="uid://dswkgkor3yejo" path="res://Scenes/Cupcakes/cupcake.tscn" id="2_fi3r2"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_sh03e"] size = Vector2(1943, 1102) @@ -9,16 +10,24 @@ size = Vector2(1943, 1102) [node name="GameWorld" type="Node2D"] script = ExtResource("1_c2sx0") +[node name="Location" type="Node2D" parent="."] + [node name="Cupcake Spawn Timer" type="Timer" parent="."] wait_time = 2.0 autostart = true script = ExtResource("2_bjylp") [node name="PlayArea" type="Area2D" parent="."] +collision_layer = 3 +collision_mask = 3 + +[node name="Cupcake" parent="PlayArea" instance=ExtResource("2_fi3r2")] [node name="CollisionShape2D" type="CollisionShape2D" parent="PlayArea"] position = Vector2(961.5, 541) shape = SubResource("RectangleShape2D_sh03e") +disabled = true [connection signal="timeout" from="Cupcake Spawn Timer" to="." method="_on_timeout"] [connection signal="area_exited" from="PlayArea" to="." method="_on_play_area_area_exited"] +[connection signal="body_exited" from="PlayArea" to="." method="_on_play_area_body_exited"] diff --git a/Scripts/Cupcakes/cupcake.gd b/Scripts/Cupcakes/cupcake.gd index cc70b29..3ad452b 100644 --- a/Scripts/Cupcakes/cupcake.gd +++ b/Scripts/Cupcakes/cupcake.gd @@ -1,7 +1,8 @@ extends RigidBody2D var speed = Vector2.ZERO -# Called when the node enters the scene tree for the first time. +var horse = preload("res://Scripts/horse.gd") + func _ready(): pass # Replace with function body. @@ -9,3 +10,5 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass + + diff --git a/Scripts/game_world.gd b/Scripts/game_world.gd index 8601c80..542d2df 100644 --- a/Scripts/game_world.gd +++ b/Scripts/game_world.gd @@ -3,10 +3,11 @@ extends Node2D var spawn var location = preload("res://Scenes/Locations/yard.tscn") var horse_scene = preload("res://Scenes/horse.tscn") +var horse = preload("res://Scripts/horse.gd") var horse_instance var mouse_position = Vector2.ZERO -@export var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn") -var ccvan +var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn") +var ccvan = ccVanilla.instantiate() var ccChocolate var ccchoc var randX @@ -17,11 +18,9 @@ var ccMaxOnScreen = 250 func _ready(): horse_instance = horse_scene.instantiate() - ccvan = ccVanilla.instantiate() spawn = location.instantiate() - add_child(spawn) + $Location.add_child(spawn) add_child(horse_instance) - add_child(ccvan) func _process(delta): @@ -30,10 +29,13 @@ func _process(delta): func spawnCupcakes(): randomize() - randX = randi_range(10, 1910) - randY = randi_range(10, 1070) - add_child(ccvan) - ccvan.position = Vector2(randX, randY) + if ccCount <= ccMaxOnScreen: + for i in range(ccSpawnRate): + randX = randi_range(10, 1910) + randY = randi_range(10, 1070) + ccvan.position = Vector2(randX, randY) + $PlayArea.add_child(ccvan.duplicate()) + ccCount = ccCount + 1 @@ -48,5 +50,20 @@ func _on_timeout(): timer.start + + func _on_play_area_area_exited(area): - pass + pass + + + + +func _on_play_area_body_exited(body): + if body.is_in_group("Cupcake"): + horse.ccVanNum += 1 + print(horse.ccVanNum) + body.queue_free() + + +func _on_play_area_area_shape_exited(area_rid, area, area_shape_index, local_shape_index): + pass # Replace with function body. diff --git a/Scripts/horse.gd b/Scripts/horse.gd index 8cc0e9d..d08778a 100644 --- a/Scripts/horse.gd +++ b/Scripts/horse.gd @@ -3,6 +3,15 @@ extends CharacterBody2D var horse_instance var mouse_position = Vector2.ZERO +#ccScore +var ccVanNum = 0 +var ccChocNum = 0 +var ccStrawNum = 0 +var ccBlueNum = 0 +var ccRVelNum = 0 + + + signal hit func _process(delta): diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..e69de29