fix spawning

This commit is contained in:
2024-07-03 14:41:24 +02:00
parent dbfff61052
commit 94e51d3009
8 changed files with 69 additions and 30 deletions

View File

@@ -1,5 +1,9 @@
extends KinematicBody2D
onready var age = 0
onready var tilesmap = $"/root/World/tilemap"
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
@@ -8,6 +12,16 @@ const MOVEMENT_VECTORS = [
]
func _physics_process(_delta):
if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
queue_free()
if age > 2500:
$"Romance".add_to_group("malegoblin")
if age > 5000:
queue_free()
else:
age = age + 1
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)