2024-08-17 19:54:37 +00:00
|
|
|
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
|
2024-08-17 19:54:37 +00:00
|
|
|
|
|
|
|
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()
|
2024-08-17 19:54:37 +00:00
|
|
|
velocity = init_velocity
|
|
|
|
|
|
|
|
func take_knockback(speed: int) -> void:
|
|
|
|
kb_speed = speed
|