This commit is contained in:
Tabby 2025-06-29 15:15:49 +10:00
parent 170916456e
commit 3e0e23c28c
6 changed files with 175 additions and 1 deletions

73
2dWorld.tscn Normal file
View file

@ -0,0 +1,73 @@
[gd_scene load_steps=4 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"]
[node name="2dWorld" type="Node2D"]
[node name="WorldMap" type="Sprite2D" parent="."]
position = Vector2(589, 319)
scale = Vector2(5, 5)
texture = ExtResource("1_2uw02")
[node name="Cyclone" type="Node2D" parent="." node_paths=PackedStringArray("sprite", "label", "wind_speed_label")]
position = Vector2(572, 229)
script = ExtResource("1_xr6w1")
sprite = NodePath("Sprite2D")
label = NodePath("cLabel")
wind_speed_label = NodePath("wsLabel")
[node name="Sprite2D" type="Sprite2D" parent="Cyclone"]
scale = Vector2(0.2, 0.2)
texture = ExtResource("1_1wkcu")
[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="Timer" type="Timer" parent="Cyclone"]
wait_time = 5.0
autostart = true
[node name="Background" type="CanvasLayer" parent="."]
layer = -1
[node name="UI" type="Control" parent="Background"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Background/UI"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="LoadImage" type="Button" parent="Background/UI/VBoxContainer"]
layout_mode = 2
text = "Load Image"
[node name="Spawn" type="Button" parent="Background/UI/VBoxContainer"]
layout_mode = 2
text = "Spawn Cyclone"
[connection signal="timeout" from="Cyclone/Timer" to="Cyclone" method="_on_timer_timeout"]

BIN
Sprites/Cyclone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cdw1vlidvg2yt"
path="res://.godot/imported/Cyclone.png-5ff4ec84cd16e1667f6ef06ee600f279.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Cyclone.png"
dest_files=["res://.godot/imported/Cyclone.png-5ff4ec84cd16e1667f6ef06ee600f279.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

66
cyclone.gd Normal file
View file

@ -0,0 +1,66 @@
extends Node2D
@export var sprite : Sprite2D
@export var label : Label
@export var wind_speed_label : Label
var wind_speed : float = 30
#var move_speed : float = 20
var wind_acceleration : float = 0.2
var wind_change : float = 0.2
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()
wind_speed_label.text = str(round(wind_speed*10)/10)
sprite.rotation_degrees += 40 * delta
if wind_speed <= 0:
end_cyclone()
wind_acceleration += wind_change * delta
wind_acceleration = clampf(wind_acceleration, -5, 5)
wind_speed += wind_acceleration * delta
move_acceleration += move_change * delta
move_acceleration.x = clampf(move_acceleration.x, -5, 5)
move_acceleration.y = clampf(move_acceleration.y, -5, 5)
velocity += move_acceleration * delta
velocity.x = clampf(velocity.x, -3, 3)
velocity.y = clampf(velocity.y, -3, 3)
position += velocity * delta
func do_something():
wind_change = randf_range(-1,1)
move_change = Vector2(randf_range(-1,1),randf_range(-1,1))
pass
func end_cyclone():
queue_free()
func get_category() -> String:
if wind_speed >= 250:
return "5"
elif wind_speed >= 210:
return "4"
elif wind_speed >= 178:
return "3"
elif wind_speed >= 154:
return "2"
elif wind_speed >= 119:
return "1"
elif wind_speed >= 63:
return "TS"
else:
return "TD"
func _on_timer_timeout() -> void:
do_something()

1
cyclone.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://u353j4q7l26d

View file

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="Cyclone Tracker" config/name="Cyclone Tracker"
run/main_scene="res://world.tscn" run/main_scene="uid://biu528mgexdyp"
config/features=PackedStringArray("4.4", "GL Compatibility") config/features=PackedStringArray("4.4", "GL Compatibility")
config/icon="res://icon.svg" config/icon="res://icon.svg"