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,23 +1,30 @@
|
|||
tool
|
||||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
enum Direction {HORIZONTAL, VERTICAL}
|
||||
|
||||
#How far to move
|
||||
export var left_up_boundary = 0.0
|
||||
export var right_down_boundary = 0.0
|
||||
export var left_up_boundary = 0.0 setget _set_left_up_boundary
|
||||
export var right_down_boundary = 0.0 setget _set_right_down_boundary
|
||||
#Start direction
|
||||
export var direction = 1
|
||||
export var speed = 50
|
||||
#Move horizontal or vertical
|
||||
export(int, "Horizontal", "Vertical") var move_direction
|
||||
export(Direction) var move_direction
|
||||
export var flip_sprite = true
|
||||
#Onreadys
|
||||
onready var startpos = position
|
||||
onready var sprite = $AnimatedSprite
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
left_up_boundary *= 8
|
||||
right_down_boundary *= 8
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if right_down_boundary == 0 and left_up_boundary == 0:
|
||||
return
|
||||
elif move_direction == 0:
|
||||
|
@ -45,3 +52,30 @@ func move_up_and_down(delta):
|
|||
if position.y <= startpos.y + (-left_up_boundary):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.y = -1
|
||||
|
||||
# editor debug drawing
|
||||
func _draw():
|
||||
if Engine.editor_hint:
|
||||
match move_direction:
|
||||
Direction.HORIZONTAL:
|
||||
draw_line(
|
||||
Vector2(-left_up_boundary * 8.0, 0.0),
|
||||
Vector2(right_down_boundary * 8.0, 0.0),
|
||||
Color(0.4, 0.2, 0.6, 0.75), 1.01, false
|
||||
)
|
||||
Direction.VERTICAL:
|
||||
draw_line(
|
||||
Vector2(0.0, -left_up_boundary * 8.0),
|
||||
Vector2(0.0, right_down_boundary * 8.0),
|
||||
Color(0.4, 0.2, 0.6, 0.75), 1.01, false
|
||||
)
|
||||
|
||||
func _set_left_up_boundary(value):
|
||||
left_up_boundary = value
|
||||
if Engine.editor_hint:
|
||||
update()
|
||||
|
||||
func _set_right_down_boundary(value):
|
||||
right_down_boundary = value
|
||||
if Engine.editor_hint:
|
||||
update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue