The Enemy class represents the aliens in our Space Invaders clone. It's very simple, and is more or less the same as the player class with the input mechanisms removed. On its own, an Enemy will move in the direction it's told to move forever. Turning around when it reaches the edge of the screen and moving down are handled by the EnemyFormation sprite group class.
class Enemy
include Sprites::Sprite
# Speed in pixels per second
SPEED = 30
def initialize(x,y)
super()
@image = Surface['enemy.png']
@rect = @image.make_rect
@rect.center = [x,y]
end
def update(delta, dir)
@rect.centerx += SPEED * delta * dir
end
end

