Class: Asteroids::Asteroid

Inherits:
GameObject show all
Defined in:
lib/asteroids/asteroid/asteroid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GameObject

#components, #draw, #mark_for_removal, #removable?, #update

Constructor Details

#initialize(object_pool, x, y, vel_x, vel_y, angle, radius = 45) ⇒ Asteroid

Returns a new instance of Asteroid.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/asteroids/asteroid/asteroid.rb', line 6

def initialize(object_pool, x, y, vel_x, vel_y, angle, radius = 45)
  super(object_pool)
  @x = x
  @y = y
  @angle = angle
  @vel_x = vel_x
  @vel_y = vel_y
  @physics = AsteroidPhysics.new(self, object_pool)
  @graphics = AsteroidGraphics.new(self)
  @radius = radius
end

Instance Attribute Details

#angleObject

Returns the value of attribute angle.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def angle
  @angle
end

#radiusObject

Returns the value of attribute radius.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def radius
  @radius
end

#vel_xObject

Returns the value of attribute vel_x.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def vel_x
  @vel_x
end

#vel_yObject

Returns the value of attribute vel_y.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def vel_y
  @vel_y
end

#xObject

Returns the value of attribute x.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def x
  @x
end

#yObject

Returns the value of attribute y.



4
5
6
# File 'lib/asteroids/asteroid/asteroid.rb', line 4

def y
  @y
end

Instance Method Details

#explodeObject



18
19
20
# File 'lib/asteroids/asteroid/asteroid.rb', line 18

def explode
  Explosion.new(object_pool, @x, @y)
end