damage on cursor bullet

This commit is contained in:
SondreElg
2025-10-05 13:21:32 +02:00
parent 34843470c4
commit ebd9ccad8c
11 changed files with 102 additions and 51 deletions

View File

@@ -27,6 +27,8 @@ var charged = false;
var dash_cooldown_timer = 0;
var dash_on_cooldown = false;
var knockback_timer: Timer = Timer.new()
func get_target_pos():
return self.get_global_mouse_position()
@@ -73,6 +75,7 @@ func dash():
func _ready():
screen_size = get_viewport_rect().size
knockback_timer.one_shot = true
func _process(delta):
update_target_coords();
@@ -87,7 +90,7 @@ func _process(delta):
dash_cooldown_timer = 0;
# handle move_state
if move_state == MoveState.Knockback:
if knockback_timer.time_left > 0:
pass
elif Input.is_action_just_pressed("dash"):
dash();
@@ -100,6 +103,22 @@ func _process(delta):
move_and_slide();
func take_hit(_damage, knockback_vector, knockback_strength = 1):
# Called when the player takes damage
if shield_active:
shield_active = false;
# TODO visualize shield
# $Shield.hide();
move_state = MoveState.Knockback;
velocity = knockback_vector;
knockback_timer.start(0.2 * knockback_strength);
else:
reboot();
func _on_timer_timeout():
pass # Replace with function body.
func reboot():
# Called when the player dies
# For now, just reset position and state
position = Vector2.ZERO;
velocity = Vector2.ZERO;
move_state = MoveState.Still;
# hand.discard_all();