update movement

This commit is contained in:
2024-07-07 20:54:47 +02:00
parent 631f8ef6e7
commit 3a88fd7031
5 changed files with 37 additions and 12 deletions

View File

@@ -11,6 +11,9 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT
]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta):
if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
@@ -21,9 +24,11 @@ func _physics_process(_delta):
queue_free()
else:
age = age + 1
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
if directioncount == 0:
direction = MOVEMENT_VECTORS[randi() % 4]
directioncount = (directioncount + 1) % 5
move_and_collide(direction * 2)
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()