Class: BulletTurret
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- BulletTurret
- Includes:
- GamespacePersistence
- Defined in:
- lib/prkwars/bullet_turret.rb
Overview
A bullet shot by the Turret enemy unit. Destroys itself if out of bounds.
Instance Method Summary collapse
-
#initialize(gamespace, options = {}) ⇒ BulletTurret
constructor
Initializes gamespace in which the bullet is present and assigns the turret.
-
#update ⇒ Object
As velocity is set by chingu, the only thing update does is that it checks whether there’s any reason for the bullets to exist - if not, they get destroyed.
Methods included from GamespacePersistence
Constructor Details
#initialize(gamespace, options = {}) ⇒ BulletTurret
Initializes gamespace in which the bullet is present and assigns the turret. Velocity of the bullet is passed as an options parameter, used by the chingu library.
16 17 18 19 20 |
# File 'lib/prkwars/bullet_turret.rb', line 16 def initialize(gamespace, = {}) super() @image = Image['media/bullet_turret.png'] @gamespace = gamespace end |
Instance Method Details
#update ⇒ Object
As velocity is set by chingu, the only thing update does is that it checks whether there’s any reason for the bullets to exist - if not, they get destroyed.
26 27 28 |
# File 'lib/prkwars/bullet_turret.rb', line 26 def update destroy! unless in_bounds(self, @gamespace) end |