Class: AMazeIng::Infor
- Inherits:
-
Object
- Object
- AMazeIng::Infor
- Defined in:
- lib/a_maze_ing/infor.rb
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#player_1_point ⇒ Object
Returns the value of attribute player_1_point.
-
#player_2_point ⇒ Object
Returns the value of attribute player_2_point.
Instance Method Summary collapse
- #center_by_x(width) ⇒ Object
- #draw ⇒ Object
-
#initialize(*player_color) ⇒ Infor
constructor
A new instance of Infor.
- #update ⇒ Object
Constructor Details
#initialize(*player_color) ⇒ Infor
Returns a new instance of Infor.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/a_maze_ing/infor.rb', line 4 def initialize(*player_color) @player_color = player_color # This class will renders information of the game, like points and level #---------------------------------------------------------------------------------# # create code block (initial, update and draw) for different game mode # #---------------------------------------------------------------------------------# if @player_color.length == 2 @initial_lambda = lambda { @player_1_color = player_color[0] @player_2_color = player_color[1] @level = 1 @level_image = Gosu::Image.from_text @level.to_s, 36 @label = 'LEVEL' @label_image = Gosu::Image.from_text @label, 40 @x = center_by_x(@label_image.width) @y_1 = 210 @y_2 = 290 @player_1_point = 0 @player_2_point = 0 @player_1_point_image = Gosu::Image.from_text @player_1_point.to_s, 36 @player_2_point_image = Gosu::Image.from_text @player_2_point.to_s, 36 } @update_lambda = lambda { @level_image = Gosu::Image.from_text @level.to_s, 36 @player_1_point_image = Gosu::Image.from_text @player_1_point.to_s, 36 @player_2_point_image = Gosu::Image.from_text @player_2_point.to_s, 36 } @draw_lambda = lambda { @label_image.draw(center_by_x(@label_image.width), 80, 1) @level_image.draw(center_by_x(@level_image.width), 130, 1) draw_quad @x, @y_1, @player_1_color, @x+30, @y_1, @player_1_color, @x+30, @y_1+30, @player_1_color, @x, @y_1+30, @player_1_color draw_quad @x, @y_2, @player_2_color, @x+30, @y_2, @player_2_color, @x+30, @y_2+30, @player_2_color, @x, @y_2+30, @player_2_color @player_1_point_image.draw(@x + 60, @y_1, 1) @player_2_point_image.draw(@x + 60, @y_2, 1) } elsif @player_color.length == 0 @initial_lambda = lambda { @level = 1 @label = 'LEVEL' @label_image = Gosu::Image.from_text @label, 40 } @update_lambda = lambda { @level_image = Gosu::Image.from_text @level.to_s, 36 } @draw_lambda = lambda { @label_image.draw(center_by_x(@label_image.width), 80, 1) @level_image.draw(center_by_x(@level_image.width), 130, 1) } end #-------------------------# # end create code block # #-------------------------# @initial_lambda.call end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
3 4 5 |
# File 'lib/a_maze_ing/infor.rb', line 3 def level @level end |
#player_1_point ⇒ Object
Returns the value of attribute player_1_point.
3 4 5 |
# File 'lib/a_maze_ing/infor.rb', line 3 def player_1_point @player_1_point end |
#player_2_point ⇒ Object
Returns the value of attribute player_2_point.
3 4 5 |
# File 'lib/a_maze_ing/infor.rb', line 3 def player_2_point @player_2_point end |
Instance Method Details
#center_by_x(width) ⇒ Object
77 78 79 |
# File 'lib/a_maze_ing/infor.rb', line 77 def center_by_x(width) return $dimension + SIDE_BAR/2 - width/2 end |
#draw ⇒ Object
85 86 87 |
# File 'lib/a_maze_ing/infor.rb', line 85 def draw @draw_lambda.call end |
#update ⇒ Object
81 82 83 |
# File 'lib/a_maze_ing/infor.rb', line 81 def update @update_lambda.call end |