Class: Bullet
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- Bullet
- Includes:
- GamespacePersistence
- Defined in:
- lib/prkwars/bullet.rb
Overview
Class representing a bullet shot by the player. Destroys itself if is present out of bounds.
Instance Method Summary collapse
-
#initialize(gamespace, options = {}) ⇒ Bullet
constructor
A new instance of Bullet.
- #update ⇒ Object
Methods included from GamespacePersistence
Constructor Details
#initialize(gamespace, options = {}) ⇒ Bullet
Returns a new instance of Bullet.
12 13 14 15 16 17 18 |
# File 'lib/prkwars/bullet.rb', line 12 def initialize(gamespace, = {}) super() @image = Image['media/bullet.png'] @gamespace = gamespace cache_bounding_box end |
Instance Method Details
#update ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/prkwars/bullet.rb', line 20 def update return if in_bounds(self, @gamespace) 2.times do ExplosionParticle.create(@gamespace, x: @x, y: @y, zorder: ZOrder::GAMEOBJECT) destroy! end end |