Class: Onsengame::Window

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Window

Returns a new instance of Window.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/onsengame/window.rb', line 9

def initialize(options={})
  width = options[:width] || 640
  height = options[:height] || 480
  fullscreen = options[:fullscreen] || false
  super(width, height, fullscreen)
  self.caption = "Onsengame"
  @options = options
  @options[:font_dir] ||= File.expand_path("../../../data/fonts", __FILE__)
  @scenes = []
  @scenes << Scene::Title.new(self)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/onsengame/window.rb', line 8

def options
  @options
end

#scenesObject (readonly)

Returns the value of attribute scenes.



8
9
10
# File 'lib/onsengame/window.rb', line 8

def scenes
  @scenes
end

Instance Method Details

#button_down(id) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/onsengame/window.rb', line 29

def button_down(id)
  case id
  when Gosu::KbEscape
    close
  else
    current_scene.button_down(id)
  end
end

#drawObject



25
26
27
# File 'lib/onsengame/window.rb', line 25

def draw
  current_scene.draw
end

#updateObject



21
22
23
# File 'lib/onsengame/window.rb', line 21

def update
  current_scene.update
end