My first 2D game in Godot 4.4

This commit is contained in:
2025-08-18 19:39:33 -04:00
commit 35600f72f9
83 changed files with 2512 additions and 0 deletions

24
player.gd Normal file
View File

@@ -0,0 +1,24 @@
extends CharacterBody2D
signal health_depleted
var health = 100.0
var move_speed := 400.0
func _physics_process(delta: float) -> void:
var direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
velocity = (direction * move_speed)
move_and_slide()
if velocity.length() > 0.0:
%HappyBoo.play_walk_animation()
else:
%HappyBoo.play_idle_animation()
const DAMAGE_RATE = 15.0
var overlapping_mobs = %Hitbox.get_overlapping_bodies()
if overlapping_mobs.size() > 0:
health -= (DAMAGE_RATE * overlapping_mobs.size()) * delta
%ProgressBar.value = health
if health <= 0.0:
health_depleted.emit()