From 0a7ac740b26badc325e0da390094792572cebb5c Mon Sep 17 00:00:00 2001 From: Harmony Honey Date: Tue, 20 Feb 2024 12:38:24 -0500 Subject: [PATCH] BoxSpawner! win screen additions (: --- src/actor/BoxSpawner.gd | 23 +++++++++++++++++++++++ src/actor/BoxSpawner.tscn | 19 +++++++++++++++++++ src/actor/Switch.gd | 12 ++++++------ src/actor/SwitchBlock.gd | 5 ++++- src/map/win.tscn | 22 +++++++++++++++------- 5 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 src/actor/BoxSpawner.gd create mode 100644 src/actor/BoxSpawner.tscn diff --git a/src/actor/BoxSpawner.gd b/src/actor/BoxSpawner.gd new file mode 100644 index 0000000..20496f1 --- /dev/null +++ b/src/actor/BoxSpawner.gd @@ -0,0 +1,23 @@ +tool +extends Actor + +var is_hit := false +var is_done := false + +onready var node_sprite : Sprite = $Sprite +onready var node_audio : AudioStreamPlayer2D = $Audio + +export var color := "red" + +var box = preload("res://src/actor/Box.tscn") + +func _ready(): + for i in get_tree().get_nodes_in_group("switch_" + color): + i.connect("press", self, "release") + +func release(): + if is_area_solid_actor(position.x, position.y): return + var b = box.instance() + b.position = position + get_parent().add_child(b) + diff --git a/src/actor/BoxSpawner.tscn b/src/actor/BoxSpawner.tscn new file mode 100644 index 0000000..b328aaa --- /dev/null +++ b/src/actor/BoxSpawner.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/actor/BoxSpawner.gd" type="Script" id=1] +[ext_resource path="res://media/image/crate.png" type="Texture" id=2] +[ext_resource path="res://media/audio/sfx/hit0.wav" type="AudioStream" id=3] + +[node name="BoxSpawner" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 4, 4 ) +texture = ExtResource( 2 ) +hframes = 16 +vframes = 8 +frame = 15 + +[node name="Audio" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 3 ) +bus = "SFX" diff --git a/src/actor/Switch.gd b/src/actor/Switch.gd index bd6393e..9bc9757 100644 --- a/src/actor/Switch.gd +++ b/src/actor/Switch.gd @@ -10,9 +10,11 @@ var is_last := false onready var node_sprite : Sprite = $Sprite onready var node_audio : AudioStreamPlayer2D = $AudioStreamPlayer2D -func _ready(): +signal press +signal release + +func _enter_tree(): if Engine.editor_hint: return - add_to_group("switch_" + color) func _physics_process(delta): @@ -39,14 +41,12 @@ func noise(): func press(): noise() node_sprite.position.y = 2 - for a in get_tree().get_nodes_in_group("switch_block_" + color): - a.switch_on() + emit_signal("press") func release(): noise() node_sprite.position.y = 0 - for a in get_tree().get_nodes_in_group("switch_block_" + color): - a.switch_off() + emit_signal("release") diff --git a/src/actor/SwitchBlock.gd b/src/actor/SwitchBlock.gd index 01a2540..aa35aa7 100644 --- a/src/actor/SwitchBlock.gd +++ b/src/actor/SwitchBlock.gd @@ -13,7 +13,10 @@ var is_switch = false func _ready(): if Engine.editor_hint: return - add_to_group("switch_block_" + color) + for i in get_tree().get_nodes_in_group("switch_" + color): + i.connect("press", self, "switch_on") + i.connect("release", self, "switch_off") + break func _physics_process(delta): if Engine.editor_hint: return diff --git a/src/map/win.tscn b/src/map/win.tscn index b25d083..a4963e2 100644 --- a/src/map/win.tscn +++ b/src/map/win.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=2] +[gd_scene load_steps=28 format=2] [ext_resource path="res://src/stage/Stage.gd" type="Script" id=1] [ext_resource path="res://src/actor/Exit.tscn" type="PackedScene" id=2] @@ -13,6 +13,7 @@ [ext_resource path="res://src/menu/hide_on_level_select.gd" type="Script" id=11] [ext_resource path="res://src/actor/Note.tscn" type="PackedScene" id=12] [ext_resource path="res://src/stage/SpikeTileMap.tscn" type="PackedScene" id=13] +[ext_resource path="res://src/actor/Switch.tscn" type="PackedScene" id=14] [ext_resource path="res://media/image/solid_bricks.png" type="Texture" id=15] [ext_resource path="res://media/image/8pixel.png" type="Texture" id=16] [ext_resource path="res://src/shader/outline2D_outer.shader" type="Shader" id=17] @@ -20,6 +21,7 @@ [ext_resource path="res://media/image/note.png" type="Texture" id=19] [ext_resource path="res://media/font/m6x11.ttf" type="DynamicFontData" id=20] [ext_resource path="res://media/image/skull.png" type="Texture" id=21] +[ext_resource path="res://src/actor/BoxSpawner.tscn" type="PackedScene" id=22] [sub_resource type="TileSet" id=1] 0/name = "solid_bricks.png 0" @@ -171,7 +173,7 @@ palette = 0 [node name="SolidTileMap" parent="." instance=ExtResource( 3 )] tile_set = SubResource( 1 ) -tile_data = PoolIntArray( -524296, 0, 0, -524295, 0, 0, -524294, 0, 0, -524293, 0, 0, -524292, 0, 0, -524291, 0, 0, -524290, 0, 0, -524289, 0, 0, -589824, 0, 0, -589823, 0, 0, -589822, 0, 0, -589821, 0, 0, -589820, 0, 0, -589819, 0, 0, -589818, 0, 0, -589817, 0, 0, -589816, 0, 0, -589815, 1, 0, -589814, 1, 0, -589813, 1, 0, -589812, 1, 0, -589811, 1, 0, -589810, 1, 0, -458760, 0, 0, -524280, 0, 0, -524274, 1, 0, -393224, 0, 0, -458744, 0, 0, -458738, 1, 0, -327688, 0, 0, -393208, 0, 0, -393202, 1, 0, -262152, 0, 0, -327672, 0, 0, -327666, 1, 0, -196616, 0, 0, -262136, 0, 0, -262130, 1, 0, -131080, 0, 0, -196600, 0, 0, -196594, 1, 0, -65544, 0, 0, -131058, 1, 0, -8, 0, 1, -65528, 536870912, 0, -65527, 1, 0, -65526, 1, 0, -65525, 1, 0, -65524, 1, 0, -65523, 1, 0, -65522, 1, 0, 65528, 536870912, 0, 8, 536870912, 1, 131064, 536870912, 0, 65544, 536870912, 0, 196600, 536870912, 0, 196601, 536870912, 0, 196602, 536870912, 1, 196603, 0, 0, 196604, 536870912, 1, 196605, 536870912, 0, 196606, 0, 0, 196607, 536870912, 1, 131072, 536870912, 0, 131073, 536870912, 1, 131074, 536870912, 1, 131075, 536870912, 0, 131076, 536870912, 1, 131077, 0, 0, 131078, 536870912, 1, 131079, 536870912, 0, 131080, 536870912, 0 ) +tile_data = PoolIntArray( -917519, 1, 0, -917518, 1, 0, -917517, 1, 0, -917516, 1, 0, -917515, 1, 0, -917514, 1, 0, -917513, 1, 0, -917512, 1, 0, -917511, 1, 0, -917510, 1, 0, -917509, 1, 0, -917508, 1, 0, -917507, 1, 0, -917506, 1, 0, -917505, 1, 0, -983040, 1, 0, -983039, 1, 0, -983038, 1, 0, -983037, 1, 0, -983036, 1, 0, -983035, 1, 0, -983034, 1, 0, -983033, 1, 0, -983032, 1, 0, -983031, 1, 0, -983030, 1, 0, -983029, 1, 0, -983028, 1, 0, -983027, 1, 0, -983026, 1, 0, -851983, 1, 0, -917490, 1, 0, -786447, 1, 0, -851954, 1, 0, -720911, 1, 0, -786418, 1, 0, -655375, 1, 0, -720882, 1, 0, -589839, 1, 0, -655346, 1, 0, -524303, 1, 0, -524297, 0, 0, -524296, 0, 0, -524295, 0, 0, -524294, 0, 0, -524293, 0, 0, -524292, 0, 0, -524291, 0, 0, -524290, 0, 0, -524289, 0, 0, -589824, 0, 0, -589823, 0, 0, -589822, 0, 0, -589821, 0, 0, -589820, 0, 0, -589819, 0, 0, -589818, 0, 0, -589817, 0, 0, -589816, 0, 0, -589810, 1, 0, -458767, 1, 0, -458761, 0, 0, -524274, 1, 0, -393231, 1, 0, -393225, 0, 0, -458744, 0, 0, -458738, 1, 0, -327695, 1, 0, -327689, 0, 0, -393208, 0, 0, -393202, 1, 0, -262159, 1, 0, -262153, 0, 0, -327672, 0, 0, -327666, 1, 0, -196623, 1, 0, -196622, 1, 0, -196621, 1, 0, -196620, 1, 0, -196619, 1, 0, -196618, 1, 0, -196617, 0, 0, -262136, 0, 0, -262130, 1, 0, -131081, 0, 0, -196600, 0, 0, -196594, 1, 0, -65545, 0, 0, -131064, 0, 0, -131058, 1, 0, -9, 0, 0, -65528, 536870912, 0, -65527, 1, 0, -65526, 1, 0, -65525, 1, 0, -65524, 1, 0, -65523, 1, 0, -65522, 1, 0, 65527, 0, 0, 8, 536870912, 1, 131063, 0, 0, 65544, 536870912, 0, 196599, 0, 0, 196600, 536870912, 0, 196601, 536870912, 0, 196602, 536870912, 1, 196603, 0, 0, 196604, 536870912, 1, 196605, 536870912, 0, 196606, 0, 0, 196607, 536870912, 1, 131072, 536870912, 0, 131073, 536870912, 1, 131074, 536870912, 1, 131075, 536870912, 0, 131076, 536870912, 1, 131077, 0, 0, 131078, 536870912, 1, 131079, 536870912, 0, 131080, 536870912, 0 ) [node name="SpikeTileMap" parent="." instance=ExtResource( 13 )] @@ -182,7 +184,7 @@ tile_data = PoolIntArray( -7, 536870916, 0, -6, 4, 1, -5, 536870916, 0, -4, 4, 3 [node name="ObscureMap" parent="." instance=ExtResource( 7 )] tile_set = SubResource( 10 ) -tile_data = PoolIntArray( -524279, 0, 0, -524278, 0, 0, -524277, 0, 0, -524276, 0, 0, -524275, 0, 0, -458743, 0, 0, -458742, 0, 0, -458741, 0, 0, -458740, 0, 0, -458739, 0, 0, -393207, 0, 0, -393206, 0, 0, -393205, 0, 0, -393204, 0, 0, -393203, 0, 0, -327671, 0, 0, -327670, 0, 0, -327669, 0, 0, -327668, 0, 0, -327667, 0, 0, -262135, 0, 0, -262134, 0, 0, -262133, 0, 0, -262132, 0, 0, -262131, 0, 0, -196599, 0, 0, -196598, 0, 0, -196597, 0, 0, -196596, 0, 0, -196595, 0, 0, -131064, 2, 2, -131063, 0, 0, -131062, 0, 0, -131061, 0, 0, -131060, 0, 0, -131059, 0, 0 ) +tile_data = PoolIntArray( -851982, 0, 0, -851981, 0, 0, -851980, 0, 0, -851979, 0, 0, -851978, 0, 0, -851977, 0, 0, -851976, 0, 0, -851975, 0, 0, -851974, 0, 0, -851973, 0, 0, -851972, 0, 0, -851971, 0, 0, -851970, 0, 0, -851969, 0, 0, -917504, 0, 0, -917503, 0, 0, -917502, 0, 0, -917501, 0, 0, -917500, 0, 0, -917499, 0, 0, -917498, 0, 0, -917497, 0, 0, -917496, 0, 0, -917495, 0, 0, -917494, 0, 0, -917493, 0, 0, -917492, 0, 0, -917491, 0, 0, -786446, 0, 0, -786445, 0, 0, -786444, 0, 0, -786443, 0, 0, -786442, 0, 0, -786441, 0, 0, -786440, 0, 0, -786439, 0, 0, -786438, 0, 0, -786437, 0, 0, -786436, 0, 0, -786435, 0, 0, -786434, 0, 0, -786433, 0, 0, -851968, 0, 0, -851967, 0, 0, -851966, 0, 0, -851965, 0, 0, -851964, 0, 0, -851963, 0, 0, -851962, 0, 0, -851961, 0, 0, -851960, 0, 0, -851959, 0, 0, -851958, 0, 0, -851957, 0, 0, -851956, 0, 0, -851955, 0, 0, -720910, 0, 0, -720909, 0, 0, -720908, 0, 0, -720907, 0, 0, -720906, 0, 0, -720905, 0, 0, -720904, 0, 0, -720903, 0, 0, -720902, 0, 0, -720901, 0, 0, -720900, 0, 0, -720899, 0, 0, -720898, 0, 0, -720897, 0, 0, -786432, 0, 0, -786431, 0, 0, -786430, 0, 0, -786429, 0, 0, -786428, 0, 0, -786427, 0, 0, -786426, 0, 0, -786425, 0, 0, -786424, 0, 0, -786423, 0, 0, -786422, 0, 0, -786421, 0, 0, -786420, 0, 0, -786419, 0, 0, -655374, 0, 0, -655373, 0, 0, -655372, 0, 0, -655371, 0, 0, -655370, 0, 0, -655369, 0, 0, -655368, 0, 0, -655367, 0, 0, -655366, 0, 0, -655365, 0, 0, -655364, 0, 0, -655363, 0, 0, -655362, 0, 0, -655361, 0, 0, -720896, 0, 0, -720895, 0, 0, -720894, 0, 0, -720893, 0, 0, -720892, 0, 0, -720891, 0, 0, -720890, 0, 0, -720889, 0, 0, -720888, 0, 0, -720887, 0, 0, -720886, 0, 0, -720885, 0, 0, -720884, 0, 0, -720883, 0, 0, -589838, 0, 0, -589837, 0, 0, -589836, 0, 0, -589835, 0, 0, -589834, 0, 0, -589833, 0, 0, -589832, 0, 0, -589831, 0, 0, -589830, 0, 0, -589829, 0, 0, -589828, 0, 0, -589827, 0, 0, -589826, 0, 0, -589825, 0, 0, -655360, 0, 0, -655359, 0, 0, -655358, 0, 0, -655357, 0, 0, -655356, 0, 0, -655355, 0, 0, -655354, 0, 0, -655353, 0, 0, -655352, 0, 0, -655351, 0, 0, -655350, 0, 0, -655349, 0, 0, -655348, 0, 0, -655347, 0, 0, -524302, 0, 0, -524301, 0, 0, -524300, 0, 0, -524299, 0, 0, -524298, 0, 0, -589815, 0, 0, -589814, 0, 0, -589813, 0, 0, -589812, 0, 0, -589811, 0, 0, -458766, 0, 0, -458765, 0, 0, -458764, 0, 0, -458763, 0, 0, -458762, 0, 0, -524280, 2, 2, -524279, 0, 0, -524278, 0, 0, -524277, 0, 0, -524276, 0, 0, -524275, 0, 0, -393230, 0, 0, -393229, 0, 0, -393228, 0, 0, -393227, 0, 0, -393226, 0, 0, -458743, 0, 0, -458742, 0, 0, -458741, 0, 0, -458740, 0, 0, -458739, 0, 0, -327694, 0, 0, -327693, 0, 0, -327692, 0, 0, -327691, 0, 0, -327690, 0, 0, -393207, 0, 0, -393206, 0, 0, -393205, 0, 0, -393204, 0, 0, -393203, 0, 0, -262158, 0, 0, -262157, 0, 0, -262156, 0, 0, -262155, 0, 0, -262154, 0, 0, -327671, 0, 0, -327670, 0, 0, -327669, 0, 0, -327668, 0, 0, -327667, 0, 0, -262135, 0, 0, -262134, 0, 0, -262133, 0, 0, -262132, 0, 0, -262131, 0, 0, -196599, 0, 0, -196598, 0, 0, -196597, 0, 0, -196596, 0, 0, -196595, 0, 0, -131063, 0, 0, -131062, 0, 0, -131061, 0, 0, -131060, 0, 0, -131059, 0, 0 ) [node name="GameCamera" parent="." instance=ExtResource( 5 )] position = Vector2( 0, -24 ) @@ -199,15 +201,21 @@ is_obscure = true [node name="Note" parent="Actors" instance=ExtResource( 12 )] position = Vector2( -99, -49 ) +[node name="Switch" parent="Actors" instance=ExtResource( 14 )] +position = Vector2( 44, 12 ) + +[node name="BoxSpawner" parent="Actors" instance=ExtResource( 22 )] +position = Vector2( 16, -64 ) + [node name="Control" type="Control" parent="."] rect_pivot_offset = Vector2( -185, -20 ) script = ExtResource( 10 ) [node name="VBox" type="VBoxContainer" parent="Control"] -margin_left = -21.0 -margin_top = -62.0 -margin_right = 19.0 -margin_bottom = -6.0 +margin_left = -56.0 +margin_top = -65.0 +margin_right = -16.0 +margin_bottom = -9.0 script = ExtResource( 11 ) [node name="Gems" type="Control" parent="Control/VBox"]