Class: Bullet
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- Bullet
- Defined in:
- lib/games_paradise/gui/gosu/chinguroids/objects.rb
Overview
BULLET
technically speaking, it's a laser, but it's still called "Bullet"
Instance Method Summary collapse
-
#initialize(options) ⇒ Bullet
constructor
A new instance of Bullet.
- #update ⇒ Object
Constructor Details
#initialize(options) ⇒ Bullet
Returns a new instance of Bullet.
174 175 176 177 178 179 180 |
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 174 def initialize() super(.merge(:image => Gosu::Image["assets/laser.png"])) @speed = 7 self.velocity_x = Gosu::offset_x(@angle, @speed) self.velocity_y = Gosu::offset_y(@angle, @speed) @max_x, @max_y, @scr_edge = $max_x, $max_y, $scr_edge end |
Instance Method Details
#update ⇒ Object
182 183 184 185 186 187 188 189 190 |
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 182 def update @y += self.velocity_y @x += self.velocity_x if @x < -@scr_edge; @x = @max_x; end # wrap beyond screen edge if @y < -@scr_edge; @y = @max_y; end if @x > @max_x; @x = -@scr_edge; end if @y > @max_y; @y = -@scr_edge; end after(550) {self.destroy} # goes through screen edges, but only to a certain distance end |