debug drawing of moving enemy paths
This commit is contained in:
parent
5862958924
commit
563bb46a44
2 changed files with 76 additions and 5 deletions
|
@ -1,8 +1,9 @@
|
|||
tool
|
||||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
export var walk_speed = 25.0
|
||||
export var left_boundary = 0.0
|
||||
export var right_boundary = 0.0
|
||||
export var left_boundary = 0.0 setget _set_left_boundary
|
||||
export var right_boundary = 0.0 setget _set_right_boundary
|
||||
export var direction = 1.0
|
||||
export var idle_turns = 4
|
||||
export var turn_time = 0.5
|
||||
|
@ -19,6 +20,9 @@ var shooting = false
|
|||
var turns = 0
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
update()
|
||||
return
|
||||
# convert boundaries into actual coordinate positions
|
||||
left_boundary = position.x - left_boundary * 8.0
|
||||
right_boundary = position.x + right_boundary * 8.0
|
||||
|
@ -28,6 +32,8 @@ func _ready():
|
|||
sprite.speed_scale = inverse_lerp(0.0, 25.0, walk_speed)
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if !shooting:
|
||||
# check for player in raycast
|
||||
var collider = shoot_cast.get_collider()
|
||||
|
@ -84,3 +90,34 @@ func _stop_shoot():
|
|||
sprite.play("walk")
|
||||
else:
|
||||
sprite.play("idle")
|
||||
|
||||
# editor debug drawing
|
||||
func _draw():
|
||||
if Engine.editor_hint:
|
||||
var left = -left_boundary * 8.0
|
||||
var right = right_boundary * 8.0
|
||||
draw_line(
|
||||
Vector2(left, 0.0),
|
||||
Vector2(right, 0.0),
|
||||
Color(0.4, 0.2, 0.6, 0.75), 1.01, false
|
||||
)
|
||||
draw_line(
|
||||
Vector2(left, 2.0),
|
||||
Vector2(left, -2.0),
|
||||
Color(0.4, 0.2, 0.6, 0.75), 1.01, false
|
||||
)
|
||||
draw_line(
|
||||
Vector2(right, 2.0),
|
||||
Vector2(right, -2.0),
|
||||
Color(0.4, 0.2, 0.6, 0.75), 1.01, false
|
||||
)
|
||||
|
||||
func _set_left_boundary(value):
|
||||
left_boundary = value
|
||||
if Engine.editor_hint:
|
||||
update()
|
||||
|
||||
func _set_right_boundary(value):
|
||||
right_boundary = value
|
||||
if Engine.editor_hint:
|
||||
update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue