Sha256: c0a41de899dd9d4ad8f5eb546e74e32ae2ebe3b98681e4187e0aba6992a97d67

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

require "gosu"
require "gosu/swig_patches"
require "gosu/patches"
require "onsengame/scene"

module Onsengame
  class Window < Gosu::Window
    attr_reader :options, :scenes
    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

    def update
      current_scene.update
    end

    def draw
      current_scene.draw
    end

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

    private
    def current_scene
      @scenes[0]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onsengame-0.0.2 lib/onsengame/window.rb
onsengame-0.0.1 lib/onsengame/window.rb