its coming together

This commit is contained in:
Tabby 2025-06-29 16:25:51 +10:00
parent 3e0e23c28c
commit 1dadffeac4
11 changed files with 290 additions and 28 deletions

View file

@ -1,13 +1,16 @@
extends Node2D
extends RigidBody2D
@export var sprite : Sprite2D
@export var label : Label
@export var wind_speed_label : Label
@export var line : Line2D
var wind_speed : float = 30
#var move_speed : float = 20
var wind_acceleration : float = 0.2
var wind_change : float = 0.2
var wind_penalty : float = 0
var sprite_spin : float = 40
var move_acceleration : Vector2 = Vector2(0,0)
var move_change : Vector2 = Vector2(0,0)
@ -21,20 +24,28 @@ func _ready() -> void:
# 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)
sprite.rotation_degrees += 40 * delta
sprite.rotation_degrees += sprite_spin * delta
if wind_speed <= 0:
end_cyclone()
wind_acceleration += wind_change * delta
wind_acceleration = clampf(wind_acceleration, -5, 5)
wind_speed += wind_acceleration * delta
if wind_speed > 140:
wind_penalty = (wind_speed-140)/140 * delta * 150
wind_speed -= wind_penalty * 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
apply_force(move_acceleration * delta * 10)
#linear_velocity += move_acceleration * delta
#linear_velocity.x = clampf(velocity.x, -3, 3)
#linear_velocity.y = clampf(velocity.y, -3, 3)
#position += velocity * delta
sprite_spin = clampf((wind_speed/250) * 180, 0, 9999)
line.global_position = Vector2(0,0)
func do_something():
@ -43,24 +54,36 @@ func do_something():
pass
func end_cyclone():
line.reparent(get_tree().get_root())
queue_free()
func get_category() -> String:
if wind_speed >= 250:
sprite.modulate = Color.DEEP_PINK
return "5"
elif wind_speed >= 210:
sprite.modulate = Color.RED
return "4"
elif wind_speed >= 178:
sprite.modulate = Color.ORANGE_RED
return "3"
elif wind_speed >= 154:
sprite.modulate = Color.ORANGE
return "2"
elif wind_speed >= 119:
sprite.modulate = Color.YELLOW
return "1"
elif wind_speed >= 63:
sprite.modulate = Color.LIME_GREEN
return "TS"
else:
sprite.modulate = Color.DODGER_BLUE
return "TD"
func _on_timer_timeout() -> void:
do_something()
func _on_new_point_timer_timeout() -> void:
line.add_point(global_position)