Class: Metro::Window

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/metro/window.rb

Overview

A subclass of the Gosu::Window which simply acts as system to shuffle in and out scenes and relay event information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height, fullscreen) ⇒ Window

Returns a new instance of Window.

Parameters:

  • width (Fixnum)

    the width of the game window

  • height (Fixnum)

    the height of the game window

  • fullscreen (TrueClass, FalseClass)

    the boolean flag to enable or disable fullscreen



26
27
28
# File 'lib/metro/window.rb', line 26

def initialize(width,height,fullscreen)
  super width, height, fullscreen
end

Instance Attribute Details

#cursorObject Also known as: needs_cursor?

Define an acessor that enables/disables the use of a cursor within the window. The value should be truthy/falsy.



79
80
81
# File 'lib/metro/window.rb', line 79

def cursor
  @cursor
end

#sceneObject

The scene of the window.

See Also:



14
15
16
# File 'lib/metro/window.rb', line 14

def scene
  @scene
end

Instance Method Details

#button_down(id) ⇒ Object

Called before #update when the user presses a button while the window has focus.



64
65
66
# File 'lib/metro/window.rb', line 64

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

#button_up(id) ⇒ Object

Called before #update when the user releases a button while the window has focus.



56
57
58
# File 'lib/metro/window.rb', line 56

def button_up(id)
  state.fire_button_up(id)
end

#dimensionsObject

Returns the dimensions of the current window.

Returns:

  • the dimensions of the current window.



71
72
73
# File 'lib/metro/window.rb', line 71

def dimensions
  Metro::Units::Dimensions.of width, height
end

#drawObject

This is called after every #update and when the OS wants the window to repaint itself.



48
49
50
# File 'lib/metro/window.rb', line 48

def draw
  scene.base_draw
end

#hide_cursorObject



90
91
92
# File 'lib/metro/window.rb', line 90

def hide_cursor
  self.cursor = false
end

#show_cursorObject



86
87
88
# File 'lib/metro/window.rb', line 86

def show_cursor
  self.cursor = true
end

#stateObject



16
17
18
# File 'lib/metro/window.rb', line 16

def state
  scene.state
end

#updateObject

This is called every update interval while the window is being shown.



38
39
40
41
42
# File 'lib/metro/window.rb', line 38

def update
  state.fire_events_for_mouse_movement
  state.fire_events_for_held_buttons
  scene.base_update
end