Spawning!

the other half of the cupcake spawn code
main
OnlyMares 2 years ago
parent a77fe53e2b
commit 4425b2326b

@ -1,3 +1,4 @@
Node2D
Sprite2D Sprite2D
CollisionShape2D CollisionShape2D
Area2D Area2D

@ -18,7 +18,7 @@ dock_5="Inspector,Node,History,Commit (14)"
[EditorNode] [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] [ScriptEditor]

@ -7,3 +7,4 @@ res://Scripts/horse.gd
res://Scripts/Cupcakes/cupcake.gd res://Scripts/Cupcakes/cupcake.gd
res://Scenes/Locations/yard.tscn res://Scenes/Locations/yard.tscn
res://README.md res://README.md
res://Scenes/UI/ingame_ui.tscn

@ -1,5 +1,5 @@
[folding] [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()] resource_unfolds=["res://Scenes/game_world.tscn::RectangleShape2D_sh03e", PackedStringArray()]
nodes_folded=[] nodes_folded=[]

@ -10,9 +10,10 @@ run_reload_scripts=true
[dialog_bounds] [dialog_bounds]
project_settings=Rect2(814, 476, 1120, 920) project_settings=Rect2(814, 506, 1120, 920)
editor_settings=Rect2(830, 460, 900, 700) editor_settings=Rect2(830, 460, 900, 700)
search_help=Rect2(640, 390, 1280, 720) search_help=Rect2(640, 390, 1280, 720)
export=Rect2(830, 430, 900, 700)
[color_picker] [color_picker]
@ -20,7 +21,7 @@ recent_presets=PackedColorArray(0, 0, 0, 1, 0.2, 0.0156863, 0.286275, 0.431373,
[recent_files] [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"] 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] [script_setup]

@ -1,3 +1,5 @@
res://Scenes/UI
/home/shobie/CupcakeRevolution1
res://Scenes/Locations res://Scenes/Locations
res://Art/Locations res://Art/Locations
res://Scripts/Cupcakes res://Scripts/Cupcakes

@ -3,7 +3,7 @@
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 10, "column": 0,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 5, "row": 5,
@ -17,16 +17,12 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 1, "column": 0,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 34, "row": 50,
"scroll_position": 5.0, "scroll_position": 4.0,
"selection": true, "selection": false,
"selection_from_column": 1,
"selection_from_line": 34,
"selection_to_column": 17,
"selection_to_line": 34,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
@ -49,10 +45,10 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 1, "column": 14,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 10, "row": 14,
"scroll_position": 0.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"

Binary file not shown.

@ -7,6 +7,7 @@
radius = 16.0 radius = 16.0
[node name="Cupcake" type="RigidBody2D"] [node name="Cupcake" type="RigidBody2D"]
collision_layer = 2
gravity_scale = 0.0 gravity_scale = 0.0
linear_damp = 6.0 linear_damp = 6.0
script = ExtResource("1_2fcqt") script = ExtResource("1_2fcqt")

@ -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

@ -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/game_world.gd" id="1_c2sx0"]
[ext_resource type="Script" path="res://Scripts/Cupcake Spawn Timer.gd" id="2_bjylp"] [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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_sh03e"]
size = Vector2(1943, 1102) size = Vector2(1943, 1102)
@ -9,16 +10,24 @@ size = Vector2(1943, 1102)
[node name="GameWorld" type="Node2D"] [node name="GameWorld" type="Node2D"]
script = ExtResource("1_c2sx0") script = ExtResource("1_c2sx0")
[node name="Location" type="Node2D" parent="."]
[node name="Cupcake Spawn Timer" type="Timer" parent="."] [node name="Cupcake Spawn Timer" type="Timer" parent="."]
wait_time = 2.0 wait_time = 2.0
autostart = true autostart = true
script = ExtResource("2_bjylp") script = ExtResource("2_bjylp")
[node name="PlayArea" type="Area2D" parent="."] [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"] [node name="CollisionShape2D" type="CollisionShape2D" parent="PlayArea"]
position = Vector2(961.5, 541) position = Vector2(961.5, 541)
shape = SubResource("RectangleShape2D_sh03e") shape = SubResource("RectangleShape2D_sh03e")
disabled = true
[connection signal="timeout" from="Cupcake Spawn Timer" to="." method="_on_timeout"] [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="area_exited" from="PlayArea" to="." method="_on_play_area_area_exited"]
[connection signal="body_exited" from="PlayArea" to="." method="_on_play_area_body_exited"]

@ -1,7 +1,8 @@
extends RigidBody2D extends RigidBody2D
var speed = Vector2.ZERO 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(): func _ready():
pass # Replace with function body. pass # Replace with function body.
@ -9,3 +10,5 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
pass pass

@ -3,10 +3,11 @@ extends Node2D
var spawn var spawn
var location = preload("res://Scenes/Locations/yard.tscn") var location = preload("res://Scenes/Locations/yard.tscn")
var horse_scene = preload("res://Scenes/horse.tscn") var horse_scene = preload("res://Scenes/horse.tscn")
var horse = preload("res://Scripts/horse.gd")
var horse_instance var horse_instance
var mouse_position = Vector2.ZERO var mouse_position = Vector2.ZERO
@export var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn") var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn")
var ccvan var ccvan = ccVanilla.instantiate()
var ccChocolate var ccChocolate
var ccchoc var ccchoc
var randX var randX
@ -17,11 +18,9 @@ var ccMaxOnScreen = 250
func _ready(): func _ready():
horse_instance = horse_scene.instantiate() horse_instance = horse_scene.instantiate()
ccvan = ccVanilla.instantiate()
spawn = location.instantiate() spawn = location.instantiate()
add_child(spawn) $Location.add_child(spawn)
add_child(horse_instance) add_child(horse_instance)
add_child(ccvan)
func _process(delta): func _process(delta):
@ -30,10 +29,13 @@ func _process(delta):
func spawnCupcakes(): func spawnCupcakes():
randomize() randomize()
randX = randi_range(10, 1910) if ccCount <= ccMaxOnScreen:
randY = randi_range(10, 1070) for i in range(ccSpawnRate):
add_child(ccvan) randX = randi_range(10, 1910)
ccvan.position = Vector2(randX, randY) 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 timer.start
func _on_play_area_area_exited(area): 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.

@ -3,6 +3,15 @@ extends CharacterBody2D
var horse_instance var horse_instance
var mouse_position = Vector2.ZERO var mouse_position = Vector2.ZERO
#ccScore
var ccVanNum = 0
var ccChocNum = 0
var ccStrawNum = 0
var ccBlueNum = 0
var ccRVelNum = 0
signal hit signal hit
func _process(delta): func _process(delta):

Loading…
Cancel
Save