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 Vector2.LEFT
] ]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta): func _physics_process(_delta):
if position != null: if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0: if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
queue_free() queue_free()
var movement = MOVEMENT_VECTORS[randi() % 4] if directioncount == 0:
move_and_collide(movement * 2) direction = MOVEMENT_VECTORS[randi() % 4]
directioncount = (directioncount + 1) % 5
move_and_collide(direction * 2)
func _on_Hurtbox_area_entered(_area): func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play() $Hurtbox/death.play()

View File

@ -14,6 +14,9 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT Vector2.LEFT
] ]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta): func _physics_process(_delta):
if crowd > 0: if crowd > 0:
crowd -= 1 crowd -= 1
@ -39,8 +42,10 @@ func _physics_process(_delta):
rootnode.add_child(malechild) rootnode.add_child(malechild)
if pregnancy > 0: if pregnancy > 0:
pregnancy = pregnancy + 1 pregnancy = pregnancy + 1
var movement = MOVEMENT_VECTORS[randi() % 4] if directioncount == 0:
move_and_collide(movement * 2) direction = MOVEMENT_VECTORS[randi() % 4]
directioncount = (directioncount + 1) % 5
move_and_collide(direction * 2)
func _on_Hurtbox_area_entered(_area): func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play() $Hurtbox/death.play()

View File

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

View File

@ -11,14 +11,19 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT Vector2.LEFT
] ]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta): func _physics_process(_delta):
if position != null: if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0: if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
queue_free() queue_free()
if immunity > 0: if immunity > 0:
immunity = immunity - 1 immunity = immunity - 1
var movement = MOVEMENT_VECTORS[randi() % 4] if directioncount == 0:
move_and_collide(movement * 2) direction = MOVEMENT_VECTORS[randi() % 4]
directioncount = (directioncount + 1) % 5
move_and_collide(direction * 2)
func _on_Hurtbox_area_entered(_area): func _on_Hurtbox_area_entered(_area):
if immunity == 0: if immunity == 0:

View File

@ -11,14 +11,19 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT Vector2.LEFT
] ]
var directioncount = 0
var direction = Vector2.ZERO
func _physics_process(_delta): func _physics_process(_delta):
if position != null: if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0: if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
queue_free() queue_free()
if immunity > 0: if immunity > 0:
immunity = immunity - 1 immunity = immunity - 1
var movement = MOVEMENT_VECTORS[randi() % 4] if directioncount == 0:
move_and_collide(movement * 2) direction = MOVEMENT_VECTORS[randi() % 4]
directioncount = (directioncount + 1) % 5
move_and_collide(direction * 2)
func _on_Hurtbox_area_entered(_area): func _on_Hurtbox_area_entered(_area):
if immunity == 0: if immunity == 0: