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 0000000..bd686d6 Binary files /dev/null and b/Sprites/spawner.png differ diff --git a/Sprites/spawner.png.import b/Sprites/spawner.png.import new file mode 100644 index 0000000..98229b4 --- /dev/null +++ b/Sprites/spawner.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bqk4uax36mf72" +path="res://.godot/imported/spawner.png-357a463fc12577bda0a71725d3464fdf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/spawner.png" +dest_files=["res://.godot/imported/spawner.png-357a463fc12577bda0a71725d3464fdf.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/cyclone_spawner.gd b/cyclone_spawner.gd new file mode 100644 index 0000000..0219de7 --- /dev/null +++ b/cyclone_spawner.gd @@ -0,0 +1,20 @@ +extends Node2D + +var loaded : bool = false +signal spawn(spawn_position : Vector2) + +# Called when the node enters the scene tree for the first time. +func _ready() -> 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()