Class: Tetris
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Tetris
- Defined in:
- lib/tetris.rb
Constant Summary collapse
- WIDTH =
480
- HEIGHT =
480
- FONT_SIZE =
40
Instance Attribute Summary collapse
-
#font ⇒ Object
readonly
Returns the value of attribute font.
Instance Method Summary collapse
- #add_score(score) ⇒ Object
- #button_down(id) ⇒ Object
- #continue ⇒ Object
- #draw ⇒ Object
- #game_running? ⇒ Boolean
- #high_score ⇒ Object
-
#initialize ⇒ Tetris
constructor
A new instance of Tetris.
- #menu ⇒ Object
- #new_game ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Tetris
Returns a new instance of Tetris.
12 13 14 15 16 17 18 19 20 |
# File 'lib/tetris.rb', line 12 def initialize super WIDTH, HEIGHT self.caption = "Tetris" @font = Gosu::Font.new(FONT_SIZE) @menu_scene = MainMenuScene.new(self) @hs_scene = HighScoreScene.new(self) @game_scene = nil @scene = @menu_scene end |
Instance Attribute Details
#font ⇒ Object (readonly)
Returns the value of attribute font.
6 7 8 |
# File 'lib/tetris.rb', line 6 def font @font end |
Instance Method Details
#add_score(score) ⇒ Object
44 45 46 |
# File 'lib/tetris.rb', line 44 def add_score(score) @hs_scene.add_score(score) end |
#button_down(id) ⇒ Object
30 31 32 |
# File 'lib/tetris.rb', line 30 def (id) @scene. id end |
#continue ⇒ Object
48 49 50 |
# File 'lib/tetris.rb', line 48 def continue @scene = @game_scene end |
#draw ⇒ Object
26 27 28 |
# File 'lib/tetris.rb', line 26 def draw @scene.draw end |
#game_running? ⇒ Boolean
52 53 54 |
# File 'lib/tetris.rb', line 52 def game_running? @game_scene&.game_running? end |
#high_score ⇒ Object
40 41 42 |
# File 'lib/tetris.rb', line 40 def high_score @scene = @hs_scene end |
#menu ⇒ Object
56 57 58 59 |
# File 'lib/tetris.rb', line 56 def #code to pause game @scene = @menu_scene end |
#new_game ⇒ Object
34 35 36 37 38 |
# File 'lib/tetris.rb', line 34 def new_game @menu_scene.add_continue @game_scene = GameScene.new(self, @menu_scene.difficulty) @scene = @game_scene end |
#update ⇒ Object
22 23 24 |
# File 'lib/tetris.rb', line 22 def update @scene.update end |