Class: BTetrisKp::BTetrisWindow

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/btetris_kp/btetris.rb

Overview

Main class maintaining game window, drawing, updating and reacting to key events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBTetrisWindow

Returns a new instance of BTetrisWindow.



11
12
13
14
15
# File 'lib/btetris_kp/btetris.rb', line 11

def initialize
  super(Const::GAME_WIDTH, Const::GAME_HEIGHT, false)
  self.caption = Const::GAME_CAPTION
  @state = MenuState.new(self)
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



9
10
11
# File 'lib/btetris_kp/btetris.rb', line 9

def state
  @state
end

Instance Method Details

#button_down(id) ⇒ Object

propagates button_down event to current window state



28
29
30
# File 'lib/btetris_kp/btetris.rb', line 28

def button_down(id)
  @state.button_down(id)
end

#drawObject

propagates draw event to current window state



23
24
25
# File 'lib/btetris_kp/btetris.rb', line 23

def draw
  @state.draw
end

#needs_cursor?Boolean

shows or hides default system cursor depending on state

Returns:

  • (Boolean)


33
34
35
# File 'lib/btetris_kp/btetris.rb', line 33

def needs_cursor?
  @state.needs_cursor?
end

#updateObject

propagates update event to current window state



18
19
20
# File 'lib/btetris_kp/btetris.rb', line 18

def update
  @state.update
end