Брождение npc
This commit is contained in:
parent
1a29a449b0
commit
81054b3572
@ -3,6 +3,9 @@ extends Node2D
|
|||||||
|
|
||||||
var id_path: Array[Vector2i]
|
var id_path: Array[Vector2i]
|
||||||
|
|
||||||
|
func is_walking() -> bool:
|
||||||
|
return not id_path.is_empty()
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
randomize()
|
randomize()
|
||||||
|
@ -13,10 +13,12 @@ func add_npc(pos: Vector2i):
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_npc(Vector2i(16, 8))
|
randomize()
|
||||||
add_npc(Vector2i(40, 32))
|
add_npc(Vector2i(11, 8))
|
||||||
set_npc_target(npcs[0], Vector2i(24, 48))
|
add_npc(Vector2i(9, 9))
|
||||||
set_npc_target(npcs[1], Vector2i(24, 49))
|
add_npc(Vector2i(12, 11))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func set_npc_target(npc: NPC, target: Vector2i):
|
func set_npc_target(npc: NPC, target: Vector2i):
|
||||||
@ -29,5 +31,8 @@ func set_npc_target(npc: NPC, target: Vector2i):
|
|||||||
npc.id_path = id_path
|
npc.id_path = id_path
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
for npc in npcs:
|
||||||
|
if not npc.is_walking():
|
||||||
|
set_npc_target(npc, Vector2i(randi()%64,randi()%64))
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user