space-invaders/scripts/enemy.gd

20 lines
402 B
GDScript3
Raw Permalink Normal View History

class_name Enemy extends StaticBody2D
# used StaticBody to get around gravity, probably a better way
2026-04-22 02:17:21 +00:00
# there is probably a better built-in to use here, maybe not for static body
@export var direction:int = 1
2026-04-22 02:17:21 +00:00
const SPEED = 1
var drop = false
2026-04-22 02:17:21 +00:00
func _ready():
pass
func go_down():
drop = true
2026-04-22 02:17:21 +00:00
func _process(_delta):
2026-04-22 02:17:21 +00:00
move_local_x(SPEED * direction)
if drop:
move_local_y(SPEED * 5)
drop = false