Class: SpaceInvaders::UBlock
- Defined in:
- lib/space_invaders/blocks/u_block.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#x_position ⇒ Object
readonly
Returns the value of attribute x_position.
-
#y_position ⇒ Object
readonly
Returns the value of attribute y_position.
Attributes inherited from Base
Instance Method Summary collapse
- #delete(block) ⇒ Object
- #draw ⇒ Object
-
#initialize(app, x_position, y_position) ⇒ UBlock
constructor
A new instance of UBlock.
- #initialize_blocks ⇒ Object
- #update ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app, x_position, y_position) ⇒ UBlock
Returns a new instance of UBlock.
9 10 11 12 13 14 15 |
# File 'lib/space_invaders/blocks/u_block.rb', line 9 def initialize app, x_position, y_position super app @x_position = x_position @y_position = y_position @blocks = [] initialize_blocks end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
7 8 9 |
# File 'lib/space_invaders/blocks/u_block.rb', line 7 def blocks @blocks end |
#x_position ⇒ Object (readonly)
Returns the value of attribute x_position.
7 8 9 |
# File 'lib/space_invaders/blocks/u_block.rb', line 7 def x_position @x_position end |
#y_position ⇒ Object (readonly)
Returns the value of attribute y_position.
7 8 9 |
# File 'lib/space_invaders/blocks/u_block.rb', line 7 def y_position @y_position end |
Instance Method Details
#delete(block) ⇒ Object
33 34 35 |
# File 'lib/space_invaders/blocks/u_block.rb', line 33 def delete(block) blocks.delete(block) end |
#draw ⇒ Object
21 22 23 |
# File 'lib/space_invaders/blocks/u_block.rb', line 21 def draw blocks.each {|block| block.draw } end |
#initialize_blocks ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/space_invaders/blocks/u_block.rb', line 25 def initialize_blocks x = [10, 10, 10, 40, 70, 70, 70] y = [10, 30, 50, 10, 10, 30, 50] 7.times do |i| @blocks << Block.new(self, x[i] + x_position, y[i] + y_position) end end |
#update ⇒ Object
17 18 19 |
# File 'lib/space_invaders/blocks/u_block.rb', line 17 def update blocks.each {|block| block.update } end |