Class: GamesAndRpgParadise::Wall
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Wall
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb
Instance Attribute Summary collapse
-
#brick_exploded ⇒ Object
Returns the value of attribute brick_exploded.
-
#bricks ⇒ Object
readonly
Returns the value of attribute bricks.
-
#struck_x ⇒ Object
Returns the value of attribute struck_x.
-
#struck_y ⇒ Object
Returns the value of attribute struck_y.
-
#time_struck ⇒ Object
Returns the value of attribute time_struck.
-
#wall_units ⇒ Object
readonly
Returns the value of attribute wall_units.
Instance Method Summary collapse
-
#check_exist ⇒ Object
check_exist.
-
#draw ⇒ Object
draw.
-
#initialize ⇒ Wall
constructor
initialize.
-
#update ⇒ Object
update.
Constructor Details
#initialize ⇒ Wall
initialize
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 17 def initialize @bricks = 64.times.map { Brick.new } @all_brick_x = (100..300).step(40).to_a + (460..660).step(40).to_a + (280..480).step(40).to_a + (0..280).step(40).to_a + (480..760).step(40).to_a + (240..520).step(40).to_a + (0..200).step(40).to_a + (360..400).step(40).to_a + (560..760).step(40).to_a + (320..440).step(40).to_a + [320] + [440] + [320] + [440] @all_brick_y = [90] * 12 + [200] * 6 + [310] * 16 + [420] * 8 + [530] * 6 + [460] * 2 + [530] * 6 + [590] * 4 + [630] * 2 + [670] * 2 @wall_units = [] (0..63).each { |n| @wall_units.push([@bricks[n]] << @all_brick_x[n] << @all_brick_y[n]) } # pack each brick profile into wall (0..63).each { |n| @wall_units[n][0].x = @wall_units.assoc(@wall_units[n][0])[1] } # write all brick instance :x (0..63).each { |n| @wall_units[n][0].y = @wall_units.assoc(@wall_units[n][0])[2] } # write all brick instance :y @struck = false @brick_explosion = Gosu::Image.load_tiles("media/brick_explode.png", 50, 50) @brick_exploded = false @time_struck = nil end |
Instance Attribute Details
#brick_exploded ⇒ Object
Returns the value of attribute brick_exploded.
12 13 14 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 12 def brick_exploded @brick_exploded end |
#bricks ⇒ Object (readonly)
Returns the value of attribute bricks.
10 11 12 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 10 def bricks @bricks end |
#struck_x ⇒ Object
Returns the value of attribute struck_x.
14 15 16 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 14 def struck_x @struck_x end |
#struck_y ⇒ Object
Returns the value of attribute struck_y.
15 16 17 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 15 def struck_y @struck_y end |
#time_struck ⇒ Object
Returns the value of attribute time_struck.
13 14 15 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 13 def time_struck @time_struck end |
#wall_units ⇒ Object (readonly)
Returns the value of attribute wall_units.
9 10 11 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 9 def wall_units @wall_units end |
Instance Method Details
#check_exist ⇒ Object
check_exist
36 37 38 39 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 36 def check_exist @bricks.select! { |brick| brick.exist } @wall_units.select! { |element| element[0].exist } end |
#draw ⇒ Object
draw
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 47 def draw @wall_units.each { |brick| brick[0].brick.draw(brick[1], brick[2], 0) } if @brick_exploded # Show the brick explosion img = @brick_explosion[Gosu::milliseconds / 25 % @brick_explosion.size] img.draw(@struck_x - 5, @struck_y - 5, 2) # Minus is for adjusting the explosion image if Time.now - @time_struck > 0.5 @brick_exploded = false end end end |
#update ⇒ Object
update
42 43 44 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/wall.rb', line 42 def update check_exist end |