2023-06-12 18:50:58 +02:00
|
|
|
class_name Enemy
|
2023-06-11 23:38:54 +02:00
|
|
|
extends CharacterBody2D
|
|
|
|
|
2023-06-12 18:50:58 +02:00
|
|
|
const Y_SPAWN_OFFSET = -8
|
|
|
|
@export var speed = 80
|
2023-06-11 23:38:54 +02:00
|
|
|
@onready var tile_map: TileMap = get_parent()
|
|
|
|
@onready var animation_player = $AnimationPlayer
|
2023-06-12 18:50:58 +02:00
|
|
|
@onready var sprite = $Sprite2D
|
2023-06-11 23:38:54 +02:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
var spawn_cell: Vector2i = tile_map.get_top_spawn_cell()
|
|
|
|
position = tile_map.map_to_local(spawn_cell)
|
2023-06-12 18:50:58 +02:00
|
|
|
position.y += Y_SPAWN_OFFSET
|