This commit is contained in:
Tabby 2025-07-04 15:14:59 +10:00
parent ab1797b9ed
commit d5455ef493
7 changed files with 239 additions and 53 deletions

View file

@ -1,23 +1,27 @@
[gd_scene load_steps=6 format=3 uid="uid://biu528mgexdyp"] [gd_scene load_steps=6 format=3 uid="uid://biu528mgexdyp"]
[ext_resource type="Texture2D" uid="uid://b48ofysofsffi" path="res://icon.svg" id="1_2uw02"]
[ext_resource type="Script" uid="uid://bdc53dgnhonif" path="res://worldManager.gd" id="1_gy87s"] [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="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://b1w10iwwhm5bj" path="res://addons/Fantail-Interactive.top_down_camera/td_camera_2d.gd" id="4_u230a"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xr6w1"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_u230a"]
size = Vector2(674, 28) size = Vector2(1292, 34)
[node name="2dWorld" type="Node2D" node_paths=PackedStringArray("camera", "map")] [node name="2dWorld" type="Node2D" node_paths=PackedStringArray("camera", "map", "cyclone_holder", "speed_slider", "speed_label", "file_picker")]
script = ExtResource("1_gy87s") script = ExtResource("1_gy87s")
camera = NodePath("TDCamera2D") camera = NodePath("TDCamera2D")
map = NodePath("WorldMap") map = NodePath("WorldMap")
cyclone_holder = NodePath("Cyclones")
speed_slider = NodePath("UI/Control/VBoxContainer/TheControls/HSlider")
speed_label = NodePath("UI/Control/VBoxContainer/TheControls/Speed label")
file_picker = NodePath("FileDialog")
[node name="WorldMap" type="Sprite2D" parent="."] [node name="WorldMap" type="Sprite2D" parent="."]
modulate = Color(1.8049e-07, 0.391665, 0.150329, 1) texture_filter = 1
position = Vector2(589, 319) position = Vector2(589, 319)
scale = Vector2(5, 5) scale = Vector2(2.5, 2.5)
texture = ExtResource("1_2uw02") texture = ExtResource("2_u230a")
[node name="Cyclones" type="Node2D" parent="."] [node name="Cyclones" type="Node2D" parent="."]
@ -30,36 +34,125 @@ position = Vector2(746, 473)
[node name="Cyclone3" parent="Cyclones" instance=ExtResource("3_u230a")] [node name="Cyclone3" parent="Cyclones" instance=ExtResource("3_u230a")]
position = Vector2(463, 494) position = Vector2(463, 494)
[node name="Background" type="CanvasLayer" parent="."] [node name="UI" type="CanvasLayer" parent="."]
layer = -1
[node name="wall" type="StaticBody2D" parent="."] [node name="Control" type="Control" parent="UI"]
position = Vector2(581, -12) layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall"] [node name="VBoxContainer" type="VBoxContainer" parent="UI/Control"]
shape = SubResource("RectangleShape2D_xr6w1") custom_minimum_size = Vector2(250, 0)
layout_mode = 1
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 128.0
grow_vertical = 2
[node name="wall2" type="StaticBody2D" parent="."] [node name="Button" type="Button" parent="UI/Control/VBoxContainer"]
position = Vector2(592, 647) layout_mode = 2
text = "Toggle Controls"
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall2"] [node name="TheControls" type="VBoxContainer" parent="UI/Control/VBoxContainer"]
shape = SubResource("RectangleShape2D_xr6w1") layout_mode = 2
[node name="wall3" type="StaticBody2D" parent="."] [node name="Speed label" type="Label" parent="UI/Control/VBoxContainer/TheControls"]
position = Vector2(259, 317) layout_mode = 2
rotation = 1.5708 text = "Speed: 1.0x"
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall3"] [node name="HSlider" type="HSlider" parent="UI/Control/VBoxContainer/TheControls"]
shape = SubResource("RectangleShape2D_xr6w1") layout_mode = 2
max_value = 6.0
value = 3.0
tick_count = 7
ticks_on_borders = true
[node name="wall4" type="StaticBody2D" parent="."] [node name="TabContainer" type="TabContainer" parent="UI/Control/VBoxContainer"]
position = Vector2(909, 326) layout_mode = 2
rotation = 1.5708 current_tab = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall4"] [node name="Tools" type="VBoxContainer" parent="UI/Control/VBoxContainer/TabContainer"]
shape = SubResource("RectangleShape2D_xr6w1") 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"]
layout_mode = 2
text = "Change Image"
[node name="Spawn" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"]
layout_mode = 2
text = "Spawn Cyclone"
[node name="Spawn2" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"]
layout_mode = 2
text = "Toggle Walls"
[node name="Exit" type="Button" parent="UI/Control/VBoxContainer/TabContainer/Tools"]
layout_mode = 2
text = "Close Program"
[node name="Settings" 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="."] [node name="TDCamera2D" type="Camera2D" parent="."]
position = Vector2(579, 330) position = Vector2(579, 330)
script = ExtResource("4_u230a") script = ExtResource("4_u230a")
min_zoom = 6.0
metadata/_custom_type_script = "uid://b1w10iwwhm5bj" metadata/_custom_type_script = "uid://b1w10iwwhm5bj"
[node name="Walls" type="Node2D" parent="."]
[node name="StaticBody2D" type="StaticBody2D" parent="Walls"]
position = Vector2(-46, -343)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/StaticBody2D"]
position = Vector2(636, 7)
shape = SubResource("RectangleShape2D_u230a")
[node name="StaticBody2D2" type="StaticBody2D" parent="Walls"]
position = Vector2(268, 968)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/StaticBody2D2"]
position = Vector2(319, 7)
shape = SubResource("RectangleShape2D_u230a")
[node name="StaticBody2D3" type="StaticBody2D" parent="Walls"]
position = Vector2(-57, 1)
rotation = 1.57079
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/StaticBody2D3"]
position = Vector2(319, 7)
shape = SubResource("RectangleShape2D_u230a")
[node name="StaticBody2D4" type="StaticBody2D" parent="Walls"]
position = Vector2(1251, 4)
rotation = 1.57079
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/StaticBody2D4"]
position = Vector2(319, 7)
shape = SubResource("RectangleShape2D_u230a")
[node name="FileDialog" type="FileDialog" parent="."]
title = "Open a File"
ok_button_text = "Open"
file_mode = 0
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"]
[connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"]

View file

@ -1,50 +1,61 @@
[gd_scene load_steps=4 format=3 uid="uid://vv75ycmtipn7"] [gd_scene load_steps=6 format=3 uid="uid://vv75ycmtipn7"]
[ext_resource type="Script" uid="uid://u353j4q7l26d" path="res://cyclone.gd" id="1_khbba"] [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"] [ext_resource type="Texture2D" uid="uid://cdw1vlidvg2yt" path="res://Sprites/Cyclone.png" id="2_7e2hf"]
[sub_resource type="CircleShape2D" id="CircleShape2D_xr6w1"] [sub_resource type="LabelSettings" id="LabelSettings_khbba"]
radius = 32.0 font_color = Color(0, 0, 0, 1)
[node name="Cyclone" type="RigidBody2D" node_paths=PackedStringArray("sprite", "label", "wind_speed_label", "line")] [sub_resource type="LabelSettings" id="LabelSettings_7e2hf"]
font_color = Color(0, 0, 0, 1)
[sub_resource type="CircleShape2D" id="CircleShape2D_xr6w1"]
radius = 4.0
[node name="Cyclone" type="RigidBody2D" node_paths=PackedStringArray("sprite", "label", "wind_speed_label", "line", "visuals")]
gravity_scale = 0.0 gravity_scale = 0.0
lock_rotation = true lock_rotation = true
script = ExtResource("1_khbba") script = ExtResource("1_khbba")
sprite = NodePath("Sprite2D") sprite = NodePath("Visuals/Sprite2D")
label = NodePath("cLabel") label = NodePath("Visuals/cLabel")
wind_speed_label = NodePath("wsLabel") wind_speed_label = NodePath("Visuals/wsLabel")
line = NodePath("Line2D") line = NodePath("Line2D")
visuals = NodePath("Visuals")
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Visuals" type="Node2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="Visuals"]
scale = Vector2(0.2, 0.2) scale = Vector2(0.2, 0.2)
texture = ExtResource("2_7e2hf") texture = ExtResource("2_7e2hf")
[node name="Line2D" type="Line2D" parent="."] [node name="cLabel" type="Label" parent="Visuals"]
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_left = -21.0
offset_top = -11.0 offset_top = -11.0
offset_right = 19.0 offset_right = 19.0
offset_bottom = 12.0 offset_bottom = 12.0
size_flags_horizontal = 4 size_flags_horizontal = 4
text = "1" text = "1"
label_settings = SubResource("LabelSettings_khbba")
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="wsLabel" type="Label" parent="."] [node name="wsLabel" type="Label" parent="Visuals"]
offset_left = -21.0 offset_left = -21.0
offset_top = -66.0 offset_top = -66.0
offset_right = 19.0 offset_right = 19.0
offset_bottom = -43.0 offset_bottom = -43.0
size_flags_horizontal = 4 size_flags_horizontal = 4
text = "1" text = "1"
label_settings = SubResource("LabelSettings_7e2hf")
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="Line2D" type="Line2D" parent="."]
position = Vector2(-572, -229)
width = 2.0
default_color = Color(0.654902, 0, 0.0823529, 0.572549)
joint_mode = 2
[node name="changeTimer" type="Timer" parent="."] [node name="changeTimer" type="Timer" parent="."]
wait_time = 5.0 wait_time = 5.0
autostart = true autostart = true

BIN
Sprites/captains_flat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View file

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

View file

@ -5,6 +5,7 @@ extends RigidBody2D
@export var label : Label @export var label : Label
@export var wind_speed_label : Label @export var wind_speed_label : Label
@export var line : Line2D @export var line : Line2D
@export var visuals : Node2D
var wind_speed : float = 0.1 var wind_speed : float = 0.1
#var move_speed : float = 20 #var move_speed : float = 20
var wind_acceleration : float = 5 var wind_acceleration : float = 5

View file

@ -1,6 +1,8 @@
# Todo # Todo
- [ ] Make cyclones loop around edges - [x] Make cyclones loop around edges - nah dont, they should just leave i think
- [ ] simulation speed control - [x] simulation speed control
- [ ] create cyclones by picking a point on the map - [ ] create cyclones by picking a point on the map
- [ ] load custom images - [ ] load custom images
- [ ] recalculate bounds based on custom images - [ ] recalculate bounds based on custom images
- [ ] landfall effect?
- [x] scale culones depending on camera zoom

View file

@ -2,7 +2,11 @@ extends Node2D
@export var camera : Camera2D @export var camera : Camera2D
@export var map : Sprite2D @export var map : Sprite2D
@export var cyclones : Array[RigidBody2D] @export var cyclone_holder : Node2D
@export var speed_slider : HSlider
@export var speed_label : Label
@export var file_picker : FileDialog
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
@ -11,7 +15,9 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
check_edges() #check_edges()
update_zoom()
update_ui()
func check_edges(): func check_edges():
#var right_center = map.global_position + Vector2(map.texture.get_width(), 0) #var right_center = map.global_position + Vector2(map.texture.get_width(), 0)
@ -20,12 +26,51 @@ func check_edges():
var map_bottom : 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_right : float = map.global_position.x + map.texture.get_width()
var map_left : 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("Top: " + str(map_top))
print("Bottom: " + str(map_top)) #print("Bottom: " + str(map_top))
print("Left: " + str(map_top)) #print("Left: " + str(map_top))
print("Right: " + str(map_top)) #print("Right: " + str(map_top))
for cyclone in cyclones: #for cyclone in cyclones:
pass #pass
pass pass
func update_zoom():
#print(1/camera.zoom.x)
var scale_level : float = clampf(1/camera.zoom.x,0,1)
for cyclone in cyclone_holder.get_children():
cyclone.visuals.scale = Vector2(scale_level,scale_level)
func update_ui():
var selected_speed : float = speed_slider.value
var actual_speed : float
# 3=1.0x, 2=0.5x, 1=0.25x, 0=0.0x, 4=2x 5=3x 6=4x
match int(selected_speed):
0:
actual_speed = 0.0001
1:
actual_speed = 0.25
2:
actual_speed = 0.5
3:
actual_speed = 1
4:
actual_speed = 2
5:
actual_speed = 4
6:
actual_speed = 8
speed_label.text = "Speed: " + str(round(actual_speed*100)/100) + "x"
Engine.time_scale = actual_speed
func _on_load_image_pressed() -> void:
file_picker.show()
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