update movement
This commit is contained in:
@@ -10,15 +10,20 @@ const MOVEMENT_VECTORS = [
|
||||
Vector2.DOWN,
|
||||
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:
|
||||
queue_free()
|
||||
if immunity > 0:
|
||||
immunity = immunity - 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):
|
||||
if immunity == 0:
|
||||
|
Reference in New Issue
Block a user