From ab1797b9ed26790ff12ca6914900a95a28b64049 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:47:54 +1000 Subject: [PATCH] meow --- 2dWorld.tscn | 71 +++++++++----------------------------------- Prefabs/cyclone.tscn | 60 +++++++++++++++++++++++++++++++++++++ cyclone.gd | 12 +++++--- readme.md | 6 ++++ worldManager.gd | 31 +++++++++++++++++++ worldManager.gd.uid | 1 + 6 files changed, 120 insertions(+), 61 deletions(-) create mode 100644 Prefabs/cyclone.tscn create mode 100644 readme.md create mode 100644 worldManager.gd create mode 100644 worldManager.gd.uid diff --git a/2dWorld.tscn b/2dWorld.tscn index cbe3436..c8ac6a1 100644 --- a/2dWorld.tscn +++ b/2dWorld.tscn @@ -1,17 +1,17 @@ -[gd_scene load_steps=7 format=3 uid="uid://biu528mgexdyp"] +[gd_scene load_steps=6 format=3 uid="uid://biu528mgexdyp"] -[ext_resource type="Texture2D" uid="uid://cdw1vlidvg2yt" path="res://Sprites/Cyclone.png" id="1_1wkcu"] [ext_resource type="Texture2D" uid="uid://b48ofysofsffi" path="res://icon.svg" id="1_2uw02"] -[ext_resource type="Script" uid="uid://u353j4q7l26d" path="res://cyclone.gd" id="1_xr6w1"] +[ext_resource type="Script" uid="uid://bdc53dgnhonif" path="res://worldManager.gd" id="1_gy87s"] +[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"] -[sub_resource type="CircleShape2D" id="CircleShape2D_xr6w1"] -radius = 32.0 - [sub_resource type="RectangleShape2D" id="RectangleShape2D_xr6w1"] size = Vector2(674, 28) -[node name="2dWorld" type="Node2D"] +[node name="2dWorld" type="Node2D" node_paths=PackedStringArray("camera", "map")] +script = ExtResource("1_gy87s") +camera = NodePath("TDCamera2D") +map = NodePath("WorldMap") [node name="WorldMap" type="Sprite2D" parent="."] modulate = Color(1.8049e-07, 0.391665, 0.150329, 1) @@ -19,56 +19,16 @@ position = Vector2(589, 319) scale = Vector2(5, 5) texture = ExtResource("1_2uw02") -[node name="Cyclone" type="RigidBody2D" parent="." node_paths=PackedStringArray("sprite", "label", "wind_speed_label", "line")] -position = Vector2(572, 229) -gravity_scale = 0.0 -lock_rotation = true -script = ExtResource("1_xr6w1") -sprite = NodePath("Sprite2D") -label = NodePath("cLabel") -wind_speed_label = NodePath("wsLabel") -line = NodePath("Line2D") +[node name="Cyclones" type="Node2D" parent="."] -[node name="Sprite2D" type="Sprite2D" parent="Cyclone"] -scale = Vector2(0.2, 0.2) -texture = ExtResource("1_1wkcu") +[node name="Cyclone" parent="Cyclones" instance=ExtResource("3_u230a")] +position = Vector2(514, 230) -[node name="Line2D" type="Line2D" parent="Cyclone"] -position = Vector2(-572, -229) -width = 2.0 -default_color = Color(0.656747, 0, 0.0830602, 1) -joint_mode = 2 +[node name="Cyclone2" parent="Cyclones" instance=ExtResource("3_u230a")] +position = Vector2(746, 473) -[node name="cLabel" type="Label" parent="Cyclone"] -offset_left = -21.0 -offset_top = -11.0 -offset_right = 19.0 -offset_bottom = 12.0 -size_flags_horizontal = 4 -text = "1" -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="wsLabel" type="Label" parent="Cyclone"] -offset_left = -21.0 -offset_top = -66.0 -offset_right = 19.0 -offset_bottom = -43.0 -size_flags_horizontal = 4 -text = "1" -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="changeTimer" type="Timer" parent="Cyclone"] -wait_time = 5.0 -autostart = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Cyclone"] -shape = SubResource("CircleShape2D_xr6w1") - -[node name="newPointTimer" type="Timer" parent="Cyclone"] -wait_time = 0.5 -autostart = true +[node name="Cyclone3" parent="Cyclones" instance=ExtResource("3_u230a")] +position = Vector2(463, 494) [node name="Background" type="CanvasLayer" parent="."] layer = -1 @@ -103,6 +63,3 @@ shape = SubResource("RectangleShape2D_xr6w1") position = Vector2(579, 330) script = ExtResource("4_u230a") metadata/_custom_type_script = "uid://b1w10iwwhm5bj" - -[connection signal="timeout" from="Cyclone/changeTimer" to="Cyclone" method="_on_timer_timeout"] -[connection signal="timeout" from="Cyclone/newPointTimer" to="Cyclone" method="_on_new_point_timer_timeout"] diff --git a/Prefabs/cyclone.tscn b/Prefabs/cyclone.tscn new file mode 100644 index 0000000..ca5bfc8 --- /dev/null +++ b/Prefabs/cyclone.tscn @@ -0,0 +1,60 @@ +[gd_scene load_steps=4 format=3 uid="uid://vv75ycmtipn7"] + +[ext_resource type="Script" uid="uid://u353j4q7l26d" path="res://cyclone.gd" id="1_khbba"] +[ext_resource type="Texture2D" uid="uid://cdw1vlidvg2yt" path="res://Sprites/Cyclone.png" id="2_7e2hf"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_xr6w1"] +radius = 32.0 + +[node name="Cyclone" type="RigidBody2D" node_paths=PackedStringArray("sprite", "label", "wind_speed_label", "line")] +gravity_scale = 0.0 +lock_rotation = true +script = ExtResource("1_khbba") +sprite = NodePath("Sprite2D") +label = NodePath("cLabel") +wind_speed_label = NodePath("wsLabel") +line = NodePath("Line2D") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.2, 0.2) +texture = ExtResource("2_7e2hf") + +[node name="Line2D" type="Line2D" parent="."] +position = Vector2(-572, -229) +width = 2.0 +default_color = Color(0.656747, 0, 0.0830602, 1) +joint_mode = 2 + +[node name="cLabel" type="Label" parent="."] +offset_left = -21.0 +offset_top = -11.0 +offset_right = 19.0 +offset_bottom = 12.0 +size_flags_horizontal = 4 +text = "1" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="wsLabel" type="Label" parent="."] +offset_left = -21.0 +offset_top = -66.0 +offset_right = 19.0 +offset_bottom = -43.0 +size_flags_horizontal = 4 +text = "1" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="changeTimer" type="Timer" parent="."] +wait_time = 5.0 +autostart = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_xr6w1") + +[node name="newPointTimer" type="Timer" parent="."] +wait_time = 0.5 +autostart = true + +[connection signal="timeout" from="changeTimer" to="." method="_on_timer_timeout"] +[connection signal="timeout" from="newPointTimer" to="." method="_on_new_point_timer_timeout"] diff --git a/cyclone.gd b/cyclone.gd index a135ba4..3e9ec91 100644 --- a/cyclone.gd +++ b/cyclone.gd @@ -5,10 +5,10 @@ extends RigidBody2D @export var label : Label @export var wind_speed_label : Label @export var line : Line2D -var wind_speed : float = 30 +var wind_speed : float = 0.1 #var move_speed : float = 20 -var wind_acceleration : float = 0.2 -var wind_change : float = 0.2 +var wind_acceleration : float = 5 +var wind_change : float = 5 var wind_penalty : float = 0 var sprite_spin : float = 40 @@ -16,16 +16,19 @@ var move_acceleration : Vector2 = Vector2(0,0) var move_change : Vector2 = Vector2(0,0) var velocity : Vector2 = Vector2(0,0) + + # 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: label.text = get_category() sprite.self_modulate = Color(1,1,1, clamp(wind_speed/20,0,1) ) - wind_speed_label.text = str(round(wind_speed*10)/10) + wind_speed_label.text = str(round(wind_speed*10)/10) + "km/h" sprite.rotation_degrees += sprite_spin * delta if wind_speed <= 0: end_cyclone() @@ -81,6 +84,7 @@ func get_category() -> String: return "TD" + func _on_timer_timeout() -> void: do_something() diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7b9f0e7 --- /dev/null +++ b/readme.md @@ -0,0 +1,6 @@ +# Todo +- [ ] Make cyclones loop around edges +- [ ] simulation speed control +- [ ] create cyclones by picking a point on the map +- [ ] load custom images + - [ ] recalculate bounds based on custom images diff --git a/worldManager.gd b/worldManager.gd new file mode 100644 index 0000000..b175f85 --- /dev/null +++ b/worldManager.gd @@ -0,0 +1,31 @@ +extends Node2D + +@export var camera : Camera2D +@export var map : Sprite2D +@export var cyclones : Array[RigidBody2D] + +# 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: + check_edges() + +func check_edges(): + #var right_center = map.global_position + Vector2(map.texture.get_width(), 0) + #var top_center = map.global_position + Vector2(0, map.texture.get_height()) + var map_top : float = map.global_position.y + map.texture.get_height() + var map_bottom : float = map.global_position.y - map.texture.get_height() + var map_right : float = map.global_position.x + map.texture.get_width() + var map_left : float = map.global_position.x - map.texture.get_width() + print("Top: " + str(map_top)) + print("Bottom: " + str(map_top)) + print("Left: " + str(map_top)) + print("Right: " + str(map_top)) + + for cyclone in cyclones: + pass + + pass diff --git a/worldManager.gd.uid b/worldManager.gd.uid new file mode 100644 index 0000000..7835575 --- /dev/null +++ b/worldManager.gd.uid @@ -0,0 +1 @@ +uid://bdc53dgnhonif