forked from team-sg/hero-mark-2
32 lines
735 B
GDScript
32 lines
735 B
GDScript
extends "res://objects/enemy/enemy.gd"
|
|
|
|
#How far to move
|
|
export var up_boundary = 0.0
|
|
export var down_boundary = 0.0
|
|
#Start direction
|
|
var direction = Vector2(1,1)
|
|
export var speed = 50
|
|
#Move horizontal or vertical
|
|
export(int, "Left To Right", "Right To Left") var move_direction
|
|
#Onreadys
|
|
onready var startpos = position
|
|
|
|
func _ready():
|
|
death_sound = Game.a_die_robot
|
|
up_boundary *= 8
|
|
down_boundary *= 8
|
|
#Move in direction selected
|
|
if move_direction == 0:
|
|
direction = Vector2(-1,-1)
|
|
|
|
func _physics_process(delta):
|
|
#Move
|
|
position += direction * (speed * delta)
|
|
#Switch dir
|
|
if position.y >= startpos.y + (down_boundary):
|
|
direction *= -1
|
|
if position.y <= startpos.y - (up_boundary):
|
|
direction *= -1
|
|
|
|
func die():
|
|
.die()
|