Sha256: cc97537dac35e4ca358f627010118a9ba8c8da76b098c7dcf210abe997687f8e

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require_relative 'helpers/example_window'

# By using a splash screen of some sort, one can switch to another resolution for the main game.
class ExampleState < Fidgit::GuiState
  def initialize
    super
    pack :vertical do
      pack :horizontal do
        text = label "Width:"

        @width_combo = combo_box(value: [640, 480]) do
          [[640, 480], [800, 600], [Gosu::screen_width, Gosu::screen_height]].each do |width, height|
            item "#{width}x#{height}", [width, height]
          end
        end
      end

      @full_screen_button = toggle_button "Fullscreen?"

      button "Load game", icon: Gosu::Image["head_icon.png"] do
        $window.close
        window = Chingu::Window.new(*@width_combo.value, @full_screen_button.value)
        window.push_game_state ExampleAfterState
        window.show
      end
    end
  end
end

class ExampleAfterState < GuiState
  def initialize
    super

    on_input(:esc, :exit)

    pack :vertical do
      label "Game loaded!", icon: Gosu::Image["head_icon.png"], border_color: Gosu::Color.rgb(255, 255, 255)
    end
  end
end

ExampleWindow.new.show

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fidgit-0.0.6alpha examples/splash_example.rb
fidgit-0.0.5alpha examples/splash_example.rb
fidgit-0.0.4alpha examples/splash_example.rb
fidgit-0.0.3alpha examples/splash_example.rb
fidgit-0.0.2alpha examples/splash_example.rb