You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
748 B
28 lines
748 B
extends Node
|
|
|
|
class_name Entity
|
|
|
|
var position: Vector3
|
|
var position2D: Vector2
|
|
var movement: int = -1
|
|
var movement_step: float = 0.0
|
|
var id = -1
|
|
|
|
signal moving
|
|
|
|
func _init(id: int, position: Vector2):
|
|
self.id = id
|
|
self.position.x = position.x
|
|
self.position.y = Global.world.get_height(Vector2(position.x, position.y))
|
|
self.position.z = position.y
|
|
position2D = position
|
|
|
|
func move(new_position: Vector2):
|
|
self.position.x = new_position.x
|
|
self.position.y = Global.world.get_height(Vector2(new_position.x, new_position.y))
|
|
self.position.z = new_position.y
|
|
position2D = new_position
|
|
Global.world.blocs[position.x][position.y].entity = -1
|
|
Global.world.blocs[new_position.x][new_position.y].entity = id
|
|
emit_signal("moving", self.position)
|
|
|
|
|