update movement

This commit is contained in:
fram3d 2024-07-07 20:54:47 +02:00
parent 631f8ef6e7
commit 3a88fd7031
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
5 changed files with 37 additions and 12 deletions

View File

@ -10,12 +10,17 @@ 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:
queue_free()
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()

View File

@ -14,6 +14,9 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT
]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta):
if crowd > 0:
crowd -= 1
@ -39,8 +42,10 @@ func _physics_process(_delta):
rootnode.add_child(malechild)
if pregnancy > 0:
pregnancy = pregnancy + 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()

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:
@ -22,8 +25,10 @@ func _physics_process(_delta):
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()

View File

@ -11,14 +11,19 @@ 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:
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:

View File

@ -11,14 +11,19 @@ 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:
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: