gmtk-2024/scripts/entity.gd
2024-08-17 22:39:51 +01:00

29 lines
637 B
GDScript

class_name Entity extends CharacterBody2D
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
move_and_slide()
velocity = init_velocity
func take_knockback(speed: int) -> void:
kb_speed = speed