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

28
monster.gd Normal file
View File

@@ -0,0 +1,28 @@
extends CharacterBody2D
var health = 3
@onready var player = get_node("/root/Game/Player")
func _ready() -> void:
%Slime.play_walk()
func _physics_process(delta: float) -> void:
var direction = global_position.direction_to(player.global_position)
velocity = direction * 200.0
move_and_slide()
func take_damage() -> void:
const SMOKE_EXPLOSION = preload("res://smoke_explosion/smoke_explosion.tscn")
%Slime.play_hurt()
health -= 1
if health == 0:
queue_free()
var s = SMOKE_EXPLOSION.instantiate()
get_parent().add_child(s)
s.global_transform = global_transform