chore: run gdformat on all gdscript files

This commit is contained in:
2025-08-19 08:43:13 +02:00
parent efb9f0d92f
commit 77f1d0811c
10 changed files with 69 additions and 24 deletions

View File

@@ -16,17 +16,22 @@ var current_progress: float = 0.0
var damaged_this_attack: Array = [] var damaged_this_attack: Array = []
var is_attacking: bool = false var is_attacking: bool = false
func _ready() -> void: func _ready() -> void:
attack_path.visible = false attack_path.visible = false
damage = default_damage damage = default_damage
func _process(delta: float) -> void: func _process(delta: float) -> void:
if timer.is_stopped() and current_progress == 0.0: if timer.is_stopped() and current_progress == 0.0:
timer.start() timer.start()
if current_progress > 0.95: if current_progress > 0.95:
reset_attack() reset_attack()
if current_target and is_instance_valid(current_target) and not current_target.is_queued_for_deletion(): if (
current_target
and is_instance_valid(current_target)
and not current_target.is_queued_for_deletion()
):
track_target(current_target) track_target(current_target)
is_attacking = true is_attacking = true
attack_path.visible = true attack_path.visible = true
@@ -37,33 +42,39 @@ func _process(delta: float) -> void:
current_progress = clampf(current_progress, 0.0, 1.0) current_progress = clampf(current_progress, 0.0, 1.0)
path_follow_2d.progress_ratio = current_progress path_follow_2d.progress_ratio = current_progress
func reset_attack() -> void: func reset_attack() -> void:
current_target = null current_target = null
attack_path.visible = false attack_path.visible = false
current_progress = 0.0 current_progress = 0.0
damaged_this_attack = [] damaged_this_attack = []
is_attacking = false is_attacking = false
position = Vector2.ZERO position = Vector2.ZERO
rotation = 0.0 rotation = 0.0
func set_target(body: Node2D): func set_target(body: Node2D):
current_target = body current_target = body
is_attacking = true is_attacking = true
func track_target(body: Node2D): func track_target(body: Node2D):
var mid_distance = attack_path.curve.get_baked_length() / 2 var mid_distance = attack_path.curve.get_baked_length() / 2
var mid_point: Vector2 = attack_path.curve.sample_baked(mid_distance) var mid_point: Vector2 = attack_path.curve.sample_baked(mid_distance)
var offset = body.global_position - to_global(mid_point) var offset = body.global_position - to_global(mid_point)
var desired_dir = (body.global_position - to_global(mid_point)).normalized() var desired_dir = (body.global_position - to_global(mid_point)).normalized()
var start_point_global = attack_path.to_global(attack_path.curve.sample_baked(0)) var start_point_global = attack_path.to_global(attack_path.curve.sample_baked(0))
var end_point_global = attack_path.to_global(attack_path.curve.sample_baked(attack_path.curve.get_baked_length())) var end_point_global = attack_path.to_global(
attack_path.curve.sample_baked(attack_path.curve.get_baked_length())
)
var curve_dir = (start_point_global - end_point_global).normalized() var curve_dir = (start_point_global - end_point_global).normalized()
var angle_diff = curve_dir.angle_to(desired_dir) var angle_diff = curve_dir.angle_to(desired_dir)
if rotation == 0.0: if rotation == 0.0:
rotation = curve_dir.angle_to(desired_dir) rotation = curve_dir.angle_to(desired_dir)
position += offset position += offset
func _on_timer_timeout() -> void: func _on_timer_timeout() -> void:
if current_target: if current_target:
if trigger_area.has_overlapping_areas(): if trigger_area.has_overlapping_areas():
@@ -75,6 +86,7 @@ func _on_timer_timeout() -> void:
if body.is_in_group(GlobalConst.GROUP_ENEMY): if body.is_in_group(GlobalConst.GROUP_ENEMY):
set_target(body) set_target(body)
func _on_attack_area_body_entered(body: Node2D) -> void: func _on_attack_area_body_entered(body: Node2D) -> void:
if not attack_path.visible: if not attack_path.visible:
return return

View File

@@ -1,7 +1,7 @@
extends Node2D extends Node2D
@export var damage_taken: float @export var damage_taken: float
@export var player_damage: bool = true @export var player_damage: bool = true
@export var critical_damage: bool = false @export var critical_damage: bool = false
@onready var animation_player: AnimationPlayer = $Control/AnimationPlayer @onready var animation_player: AnimationPlayer = $Control/AnimationPlayer
@@ -11,6 +11,7 @@ const COLOR_CRIT = Color.GOLD
const COLOR_REGULAR = Color.WHITE const COLOR_REGULAR = Color.WHITE
const COLOR_PLAYER = Color.CRIMSON const COLOR_PLAYER = Color.CRIMSON
func _ready() -> void: func _ready() -> void:
if !player_damage: if !player_damage:
label.add_theme_color_override("font_color", COLOR_PLAYER) label.add_theme_color_override("font_color", COLOR_PLAYER)
@@ -20,6 +21,7 @@ func _ready() -> void:
label.text = "%0.0f" % damage_taken label.text = "%0.0f" % damage_taken
animation_player.play("normal_damage") animation_player.play("normal_damage")
animation_player.animation_finished.connect(_on_animation_finished) animation_player.animation_finished.connect(_on_animation_finished)
func _on_animation_finished(_name: String): func _on_animation_finished(_name: String):
queue_free() queue_free()

View File

@@ -15,12 +15,14 @@ var max_health: float
var god_mode: bool = false var god_mode: bool = false
var is_dead: bool = false var is_dead: bool = false
func _ready() -> void: func _ready() -> void:
move_speed = default_move_speed move_speed = default_move_speed
max_health = default_max_health max_health = default_max_health
health = max_health health = max_health
GlobalConst.sig_debug_enemy_god_mode.connect(enemy_god_mode_toggle) GlobalConst.sig_debug_enemy_god_mode.connect(enemy_god_mode_toggle)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if target: if target:
var direction = global_position.direction_to(target.global_position) var direction = global_position.direction_to(target.global_position)
@@ -31,6 +33,7 @@ func _physics_process(delta: float) -> void:
else: else:
deal_damage() deal_damage()
func take_damage(value: float): func take_damage(value: float):
if god_mode: if god_mode:
return return
@@ -40,13 +43,15 @@ func take_damage(value: float):
add_child(dm) add_child(dm)
if health <= 0: if health <= 0:
die() die()
func deal_damage(): func deal_damage():
if target.is_in_group("damagable"): if target.is_in_group("damagable"):
if contact_damage_cd.is_stopped(): if contact_damage_cd.is_stopped():
target.take_damage(default_contact_damage) target.take_damage(default_contact_damage)
contact_damage_cd.start() contact_damage_cd.start()
func die(): func die():
if is_dead: if is_dead:
return return
@@ -56,13 +61,16 @@ func die():
animation_player.play("die") animation_player.play("die")
animation_player.animation_finished.connect(_on_die_anim_finished) animation_player.animation_finished.connect(_on_die_anim_finished)
func cheer_anim(): func cheer_anim():
if not animation_player.is_playing(): if not animation_player.is_playing():
animation_player.play("jump") animation_player.play("jump")
func enemy_god_mode_toggle(toggle_on: bool) -> void: func enemy_god_mode_toggle(toggle_on: bool) -> void:
god_mode = toggle_on god_mode = toggle_on
func _on_die_anim_finished(name: String): func _on_die_anim_finished(name: String):
visible = false visible = false
queue_free() queue_free()

View File

@@ -2,9 +2,11 @@ extends Node2D
@onready var main_ui: MainUI = $MainUI @onready var main_ui: MainUI = $MainUI
@onready var main_camera: Camera2D = $MainCamera @onready var main_camera: Camera2D = $MainCamera
func _ready(): func _ready():
GlobalConst.sig_debug_camera_zoom.connect(debug_zoom) GlobalConst.sig_debug_camera_zoom.connect(debug_zoom)
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel"): if event.is_action_pressed("ui_cancel"):
print_debug("pause") print_debug("pause")
@@ -12,6 +14,7 @@ func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("debug_menu"): if event.is_action_pressed("debug_menu"):
main_ui.debug_ui.toggle() main_ui.debug_ui.toggle()
func debug_zoom(toggled_on: bool): func debug_zoom(toggled_on: bool):
if toggled_on: if toggled_on:
main_camera.zoom = Vector2(1, 1) main_camera.zoom = Vector2(1, 1)

View File

@@ -6,32 +6,40 @@ extends Control
var debug_stats: Dictionary = {} var debug_stats: Dictionary = {}
func _ready() -> void: func _ready() -> void:
stats_container.visible = false stats_container.visible = false
panel_container.visible = false panel_container.visible = false
GlobalConst.sig_debug_stats_set.connect(set_debug_stat) GlobalConst.sig_debug_stats_set.connect(set_debug_stat)
func toggle(): func toggle():
panel_container.visible = !panel_container.visible panel_container.visible = !panel_container.visible
func _on_zoom_check_toggled(toggled_on: bool) -> void: func _on_zoom_check_toggled(toggled_on: bool) -> void:
GlobalConst.sig_debug_camera_zoom.emit(toggled_on) GlobalConst.sig_debug_camera_zoom.emit(toggled_on)
func _on_god_mode_check_toggled(toggled_on: bool) -> void: func _on_god_mode_check_toggled(toggled_on: bool) -> void:
GlobalConst.sig_debug_god_mode.emit(toggled_on) GlobalConst.sig_debug_god_mode.emit(toggled_on)
func _on_enemy_god_mode_check_toggled(toggled_on: bool) -> void: func _on_enemy_god_mode_check_toggled(toggled_on: bool) -> void:
GlobalConst.sig_debug_enemy_god_mode.emit(toggled_on) GlobalConst.sig_debug_enemy_god_mode.emit(toggled_on)
func _on_stats_check_toggled(toggled_on: bool) -> void: func _on_stats_check_toggled(toggled_on: bool) -> void:
stats_container.visible = toggled_on stats_container.visible = toggled_on
func set_debug_stat(key: String, value: String): func set_debug_stat(key: String, value: String):
if key == "": if key == "":
debug_stats.erase(key) debug_stats.erase(key)
debug_stats[key] = value debug_stats[key] = value
update_debug_stats() update_debug_stats()
func update_debug_stats() -> void: func update_debug_stats() -> void:
for child in stats_container.get_children(): for child in stats_container.get_children():
child.queue_free() child.queue_free()

View File

@@ -9,6 +9,7 @@ extends Node2D
var enemy_scene = preload("res://scenes/enemies/enemy.tscn") var enemy_scene = preload("res://scenes/enemies/enemy.tscn")
func _ready() -> void: func _ready() -> void:
timer.wait_time = spawn_rate / 1 timer.wait_time = spawn_rate / 1
timer.start() timer.start()
@@ -23,7 +24,8 @@ func _on_timer_timeout() -> void:
new_enemy.position = target.position + Vector2(50, 50) new_enemy.position = target.position + Vector2(50, 50)
new_enemy.target = target new_enemy.target = target
add_child(new_enemy) add_child(new_enemy)
func _on_stop_spawning(val: bool): func _on_stop_spawning(val: bool):
if val: if val:
timer.stop() timer.stop()

View File

@@ -5,6 +5,7 @@ extends Control
@onready var player_ui: PlayerUI = $CanvasLayer/PlayerUI @onready var player_ui: PlayerUI = $CanvasLayer/PlayerUI
@onready var debug_ui: DebugUI = $CanvasLayer/DebugUI @onready var debug_ui: DebugUI = $CanvasLayer/DebugUI
func _ready() -> void: func _ready() -> void:
pause_ui.visible = false pause_ui.visible = false
player_ui.visible = true player_ui.visible = true

View File

@@ -1,9 +1,11 @@
class_name PauseUI class_name PauseUI
extends Control extends Control
func _ready() -> void: func _ready() -> void:
pass pass
func toggle_pause_ui() -> void: func toggle_pause_ui() -> void:
if visible: if visible:
visible = false visible = false
@@ -18,7 +20,7 @@ func _on_resume_button_pressed() -> void:
func _on_options_button_pressed() -> void: func _on_options_button_pressed() -> void:
pass # Replace with function body. pass # Replace with function body.
func _on_exit_button_pressed() -> void: func _on_exit_button_pressed() -> void:
@@ -26,4 +28,4 @@ func _on_exit_button_pressed() -> void:
func _on_new_game_btuton_pressed() -> void: func _on_new_game_btuton_pressed() -> void:
pass # Replace with function body. pass # Replace with function body.

View File

@@ -3,5 +3,6 @@ extends Control
@onready var hp_bar: ProgressBar = $CenterContainer/ProgressBar @onready var hp_bar: ProgressBar = $CenterContainer/ProgressBar
func set_hp(value: float): func set_hp(value: float):
hp_bar.value = value hp_bar.value = value

View File

@@ -14,6 +14,7 @@ var dead: bool = false
var death_anim_done: bool = false var death_anim_done: bool = false
var god_mode: bool = false var god_mode: bool = false
func _ready() -> void: func _ready() -> void:
camera.position = global_position camera.position = global_position
movement_speed = default_movement_speed movement_speed = default_movement_speed
@@ -22,6 +23,7 @@ func _ready() -> void:
main_ui.player_ui.set_hp(100) main_ui.player_ui.set_hp(100)
GlobalConst.sig_debug_god_mode.connect(toggle_god_mode) GlobalConst.sig_debug_god_mode.connect(toggle_god_mode)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if dead: if dead:
return return
@@ -29,12 +31,14 @@ func _physics_process(delta: float) -> void:
velocity = input_direction * movement_speed velocity = input_direction * movement_speed
move_and_slide() move_and_slide()
func _process(delta: float) -> void: func _process(delta: float) -> void:
camera.position_smoothing_enabled = true camera.position_smoothing_enabled = true
camera.position = global_position camera.position = global_position
if dead and !death_anim_done: if dead and !death_anim_done:
death_animation(delta) death_animation(delta)
func take_damage(value: float) -> void: func take_damage(value: float) -> void:
if dead or god_mode: if dead or god_mode:
return return
@@ -48,6 +52,7 @@ func take_damage(value: float) -> void:
if health <= 0: if health <= 0:
die() die()
func die(): func die():
dead = true dead = true
remove_from_group("damagable") remove_from_group("damagable")
@@ -56,14 +61,16 @@ func die():
sprite_2d.z_index += 10 sprite_2d.z_index += 10
get_taunted() get_taunted()
func death_animation(delta: float): func death_animation(delta: float):
# Engine.time_scale = clampf(lerpf(Engine.time_scale, 0.25, 0.5), 0.25, 0.9*delta) # Engine.time_scale = clampf(lerpf(Engine.time_scale, 0.25, 0.5), 0.25, 0.9*delta)
camera.zoom = lerp(camera.zoom, Vector2(8,8), 0.99*delta) camera.zoom = lerp(camera.zoom, Vector2(8, 8), 0.99 * delta)
rotation_degrees = lerpf(rotation_degrees, 90, 0.99*delta) rotation_degrees = lerpf(rotation_degrees, 90, 0.99 * delta)
if rotation_degrees > 88: if rotation_degrees > 88:
main_ui.pause_ui.toggle_pause_ui() main_ui.pause_ui.toggle_pause_ui()
death_anim_done = true death_anim_done = true
func get_taunted(): func get_taunted():
var taunting_enemies: Array[Enemy] = [] var taunting_enemies: Array[Enemy] = []
for body in get_tree().get_nodes_in_group(GlobalConst.GROUP_ENEMY): for body in get_tree().get_nodes_in_group(GlobalConst.GROUP_ENEMY):
@@ -80,8 +87,7 @@ func get_taunted():
add_child(new_target) add_child(new_target)
new_target.add_child(collision) new_target.add_child(collision)
taunting_enemies[i].target = new_target taunting_enemies[i].target = new_target
func toggle_god_mode(value: bool): func toggle_god_mode(value: bool):
god_mode = value god_mode = value