gmtk-2024/scripts/entity.gd

30 lines
637 B
GDScript3
Raw Permalink Normal View History

class_name Entity extends CharacterBody2D
2024-08-17 21:39:51 +00:00
var health = null
var speed = null
var damage = null
var kb_speed = null
func _init(initial_health: int, speed_multiplier: int, attack_damage: int) -> void:
health = initial_health
speed = speed_multiplier
damage = attack_damage
kb_speed = 0
func _physics_process(delta: float) -> void:
var init_velocity = velocity
velocity.x = 0
velocity.y = 0
if init_velocity.x == 0:
init_velocity.x = 1
if kb_speed > 0:
velocity.x = -sign(init_velocity.x) * kb_speed
kb_speed = 0
2024-08-17 21:39:51 +00:00
move_and_slide()
velocity = init_velocity
func take_knockback(speed: int) -> void:
kb_speed = speed