From 0191cadf6acf687024b9c6883ef4acb944430ed5 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Fri, 4 Jul 2025 17:53:08 +1000 Subject: [PATCH] its done? --- 2dWorld.tscn | 81 ++++++++++++++++++------------------- Sprites/spawner.png | Bin 0 -> 1152 bytes Sprites/spawner.png.import | 34 ++++++++++++++++ cyclone_spawner.gd | 20 +++++++++ cyclone_spawner.gd.uid | 1 + project.godot | 11 +++++ readme.md | 5 ++- worldManager.gd | 29 +++++++++++++ 8 files changed, 138 insertions(+), 43 deletions(-) create mode 100644 Sprites/spawner.png create mode 100644 Sprites/spawner.png.import create mode 100644 cyclone_spawner.gd create mode 100644 cyclone_spawner.gd.uid diff --git a/2dWorld.tscn b/2dWorld.tscn index 4644ab8..d59e6f3 100644 --- a/2dWorld.tscn +++ b/2dWorld.tscn @@ -1,21 +1,25 @@ -[gd_scene load_steps=6 format=3 uid="uid://biu528mgexdyp"] +[gd_scene load_steps=7 format=3 uid="uid://biu528mgexdyp"] [ext_resource type="Script" uid="uid://bdc53dgnhonif" path="res://worldManager.gd" id="1_gy87s"] [ext_resource type="Texture2D" uid="uid://c4auuun5q0gjy" path="res://Sprites/captains_flat.png" id="2_u230a"] -[ext_resource type="PackedScene" uid="uid://vv75ycmtipn7" path="res://Prefabs/cyclone.tscn" id="3_u230a"] [ext_resource type="Script" uid="uid://b1w10iwwhm5bj" path="res://addons/Fantail-Interactive.top_down_camera/td_camera_2d.gd" id="4_u230a"] +[ext_resource type="Script" uid="uid://c31ds6gafd223" path="res://cyclone_spawner.gd" id="5_3wvl1"] +[ext_resource type="Texture2D" uid="uid://bqk4uax36mf72" path="res://Sprites/spawner.png" id="6_3wvl1"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_u230a"] size = Vector2(1292, 34) -[node name="2dWorld" type="Node2D" node_paths=PackedStringArray("camera", "map", "cyclone_holder", "speed_slider", "speed_label", "file_picker")] +[node name="2dWorld" type="Node2D" node_paths=PackedStringArray("camera", "map", "cyclone_holder", "speed_slider", "speed_label", "file_picker", "spawner_prop", "walls_node", "walls_button")] script = ExtResource("1_gy87s") camera = NodePath("TDCamera2D") map = NodePath("WorldMap") cyclone_holder = NodePath("Cyclones") -speed_slider = NodePath("UI/Control/VBoxContainer/TheControls/HSlider") -speed_label = NodePath("UI/Control/VBoxContainer/TheControls/Speed label") +speed_slider = NodePath("UI/Control/VBoxContainer/TabContainer/Show Controls/HSlider") +speed_label = NodePath("UI/Control/VBoxContainer/TabContainer/Show Controls/Speed label") file_picker = NodePath("FileDialog") +spawner_prop = NodePath("CycloneSpawner") +walls_node = NodePath("Walls") +walls_button = NodePath("UI/Control/VBoxContainer/TabContainer/Show Controls/Walls") [node name="WorldMap" type="Sprite2D" parent="."] texture_filter = 1 @@ -25,15 +29,6 @@ texture = ExtResource("2_u230a") [node name="Cyclones" type="Node2D" parent="."] -[node name="Cyclone" parent="Cyclones" instance=ExtResource("3_u230a")] -position = Vector2(514, 230) - -[node name="Cyclone2" parent="Cyclones" instance=ExtResource("3_u230a")] -position = Vector2(746, 473) - -[node name="Cyclone3" parent="Cyclones" instance=ExtResource("3_u230a")] -position = Vector2(463, 494) - [node name="UI" type="CanvasLayer" parent="."] [node name="Control" type="Control" parent="UI"] @@ -53,61 +48,53 @@ anchor_bottom = 1.0 offset_right = 128.0 grow_vertical = 2 -[node name="Button" type="Button" parent="UI/Control/VBoxContainer"] +[node name="TabContainer" type="TabContainer" parent="UI/Control/VBoxContainer"] layout_mode = 2 -text = "Toggle Controls" +current_tab = 0 -[node name="TheControls" type="VBoxContainer" parent="UI/Control/VBoxContainer"] +[node name="Show Controls" type="VBoxContainer" parent="UI/Control/VBoxContainer/TabContainer"] layout_mode = 2 +metadata/_tab_index = 0 -[node name="Speed label" type="Label" parent="UI/Control/VBoxContainer/TheControls"] +[node name="Speed label" type="Label" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 text = "Speed: 1.0x" -[node name="HSlider" type="HSlider" parent="UI/Control/VBoxContainer/TheControls"] +[node name="HSlider" type="HSlider" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 max_value = 6.0 value = 3.0 tick_count = 7 ticks_on_borders = true -[node name="TabContainer" type="TabContainer" parent="UI/Control/VBoxContainer"] -layout_mode = 2 -current_tab = 0 - -[node name="Tools" type="VBoxContainer" parent="UI/Control/VBoxContainer/TabContainer"] -layout_mode = 2 -metadata/_tab_index = 0 - -[node name="meow" type="Label" parent="UI/Control/VBoxContainer/TabContainer/Tools"] -layout_mode = 2 -text = "meow" - -[node name="LoadImage" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"] +[node name="LoadImage" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 text = "Change Image" -[node name="Spawn" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"] +[node name="Spawn" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 text = "Spawn Cyclone" -[node name="Spawn2" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"] +[node name="meow" type="Label" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] +layout_mode = 2 +text = "(Press ESC to cancel spawn)" + +[node name="Walls" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 text = "Toggle Walls" -[node name="Exit" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"] +[node name="HSeparator" type="HSeparator" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] +layout_mode = 2 + +[node name="Exit" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Show Controls"] layout_mode = 2 text = "Close Program" -[node name="Settings" type="VBoxContainer" parent="UI/Control/VBoxContainer/TabContainer"] +[node name="Hide" type="VBoxContainer" parent="UI/Control/VBoxContainer/TabContainer"] visible = false layout_mode = 2 metadata/_tab_index = 1 -[node name="meow" type="Label" parent="UI/Control/VBoxContainer/TabContainer/Settings"] -layout_mode = 2 -text = "meow" - [node name="TDCamera2D" type="Camera2D" parent="."] position = Vector2(579, 330) script = ExtResource("4_u230a") @@ -154,5 +141,17 @@ access = 2 filters = PackedStringArray("*.png") use_native_dialog = true -[connection signal="pressed" from="UI/Control/VBoxContainer/TabContainer/Tools/LoadImage" to="." method="_on_load_image_pressed"] +[node name="CycloneSpawner" type="Node2D" parent="."] +visible = false +script = ExtResource("5_3wvl1") + +[node name="Sprite2D" type="Sprite2D" parent="CycloneSpawner"] +scale = Vector2(0.5, 0.5) +texture = ExtResource("6_3wvl1") + +[connection signal="pressed" from="UI/Control/VBoxContainer/TabContainer/Show Controls/LoadImage" to="." method="_on_load_image_pressed"] +[connection signal="pressed" from="UI/Control/VBoxContainer/TabContainer/Show Controls/Spawn" to="." method="_on_spawn_pressed"] +[connection signal="pressed" from="UI/Control/VBoxContainer/TabContainer/Show Controls/Walls" to="." method="_on_walls_pressed"] +[connection signal="pressed" from="UI/Control/VBoxContainer/TabContainer/Show Controls/Exit" to="." method="_on_exit_pressed"] [connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"] +[connection signal="spawn" from="CycloneSpawner" to="." method="_on_cyclone_spawner_spawn"] diff --git a/Sprites/spawner.png b/Sprites/spawner.png new file mode 100644 index 0000000000000000000000000000000000000000..bd686d6a9cc5fe4b08149a55ea0de9f0b4ce286c GIT binary patch literal 1152 zcmeAS@N?(olHy`uVBq!ia0vp^DImNS%G~10G|-oO$`74-(dKk#qb{}!oXmj{9-?lVl4^s3;quT48OPW1p@^*3p^r= z85sBugD~Uq{1qUpBuZQ(N`mv#O3D+9QW*jgGxJLH{9Hp6O!W-)ETl7EtpKXomKx!i z=IN=$zyUIrL5h);ff2~^0%B<>8{~2gMrN=$6Oe7l$iyH3q@#d1vz-Mjo&{usKmrhh z^uuU0OBsNEpTN$*0#spOWNg5=0Aeag2kQceNmGDq5MTnD!vt0tWN86pL3J4#7=UC~ zHz*1R&$G~AU|?qUba4#HaK1Y|ut-^v$7S>Geg9{QUl3N7U_8|PcVhTdiKth3yB}#C zw_mSd&(|}pMeJlrV(O`?&JCP8eUUi=n_IpzUN+=Z+_1x^ZO7q+Vu`+jyvDD`G8)bv z0D%R^uYU}gARDnlVfzj(HV2tQQVM1jO0St_eOi9NH8Ip-^BvPN)-BxIQ&M+n>WEFy zX`Zxmy?Dgw1zUK$)2_Wc7sR$SImpOtdw7_UhVAA_3-|8aIKlBIOEKHh1pOXij(i6P zCdJ3o3hKF)+*Enym+mmUKJnsZKK&K*By8RnEGqNaka@@)mIUkzHcS1=x`pUCo% z>(#8@{l9OkK0Pa%rx@cHt0=qseWI%7x7F=`HOw~_otcqsY1TK(Wk-@bXZFrTPgJ%{ zE>3G{uK5@qE`+J#5vk=UDS+`Po83a{h9R-^MCh6b8c!X zT1BQ=k#YgL=oL87o z@sszd(NjmyJ*p8-bC!KxaH7;_P0NOLDtCmm6j!xf4R{jjy`*Jg={00g2j+qA@&G_opWFQ{4tYw-}ikU&whpNBqS;xyCYA8p6N(}~2S3j3^P6 void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + visible = loaded + if loaded: + global_position = get_global_mouse_position() + if(Input.is_action_just_pressed("spawn")): + loaded = false + spawn.emit(get_global_mouse_position()) + if(Input.is_action_just_pressed("cancel_spawn")): + loaded = false diff --git a/cyclone_spawner.gd.uid b/cyclone_spawner.gd.uid new file mode 100644 index 0000000..657777e --- /dev/null +++ b/cyclone_spawner.gd.uid @@ -0,0 +1 @@ +uid://c31ds6gafd223 diff --git a/project.godot b/project.godot index 3c115f2..edaede6 100644 --- a/project.godot +++ b/project.godot @@ -76,8 +76,19 @@ zoom_out={ "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(129, 16),"global_position":Vector2(138, 64),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } +spawn={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(85, 25),"global_position":Vector2(94, 73),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} +cancel_spawn={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [rendering] renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +environment/defaults/default_clear_color=Color(0.764706, 0.85098, 0.921569, 1) diff --git a/readme.md b/readme.md index 3f38c20..735d395 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,8 @@ - [x] Make cyclones loop around edges - nah dont, they should just leave i think - [x] simulation speed control - [ ] create cyclones by picking a point on the map -- [ ] load custom images +- [x] load custom images - [ ] recalculate bounds based on custom images -- [ ] landfall effect? +- [ ] landfall effect? nuh uh - [x] scale culones depending on camera zoom +- [ ] ui stuff diff --git a/worldManager.gd b/worldManager.gd index 94f3816..742a1c5 100644 --- a/worldManager.gd +++ b/worldManager.gd @@ -7,6 +7,11 @@ extends Node2D @export var speed_slider : HSlider @export var speed_label : Label @export var file_picker : FileDialog +@export var spawner_prop : Node2D + +@export var walls_node : Node2D +var walls_active = true +@export var walls_button : Button # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -64,6 +69,12 @@ func update_ui(): speed_label.text = "Speed: " + str(round(actual_speed*100)/100) + "x" Engine.time_scale = actual_speed + if(walls_active): + walls_button.text = "Toggle Walls: On" + walls_node.position.x = 0 + else: + walls_button.text = "Toggle Walls: Off" + walls_node.position.x = 1000000 func _on_load_image_pressed() -> void: @@ -74,3 +85,21 @@ func _on_file_dialog_file_selected(path: String) -> void: var new_image : Image = Image.load_from_file(path) var image_texture : ImageTexture = ImageTexture.create_from_image(new_image) map.texture = image_texture + + +func _on_spawn_pressed() -> void: + spawner_prop.loaded = !spawner_prop.loaded + + +func _on_cyclone_spawner_spawn(spawn_position: Vector2) -> void: + var new_cyclone : Node2D = load("res://Prefabs/cyclone.tscn").instantiate() + new_cyclone.global_position = spawn_position + cyclone_holder.add_child(new_cyclone) + + +func _on_walls_pressed() -> void: + walls_active = !walls_active + + +func _on_exit_pressed() -> void: + get_tree().quit()