Sha256: 92e5b31283598fa169be5d4ae19eadb69bba0c9bbf5d932abc0c9f93d7fe6b17

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 Bytes

Contents

module Gosuplus
  class StateManager
    def initialize(window)
      @states = []
      @index = 0
    end

    def update
      @states[@index].update if @states.size > 0
    end

    def draw
      @states[@index].draw if @states.size > 0
    end

    def handle_input(key, type)
      @states[@index].handle_input(key, type) if @states.size > 0
    end

    def next
      @states[@index].on_exit
      @states[@index].on_load
      @index += 1
    end

    def previous
      @states[@index].on_exit
      @states[@index].on_load
      @index -= 1
    end

    def add(state)
      state.on_load unless @states.size > 0

      @states << state
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
Gosuplus-1.0.23 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.22 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.21 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.20 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.19 lib/Gosuplus/statemanager.rb