Sha256: 0ab41d30f80428c1f40dd087a4bc41036f074d4cb0683df15204eaf228563114

Contents?: true

Size: 643 Bytes

Versions: 9

Compression:

Stored size: 643 Bytes

Contents

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

    def update
      @states[@index].update
    end

    def draw
      @states[@index].draw
    end

    def handle_input(key, type)
      @states[@index].handle_input(key, type)
    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

9 entries across 9 versions & 1 rubygems

Version Path
Gosuplus-1.0.18 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.17 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.16 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.15 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.14 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.13 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.12 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.11 lib/Gosuplus/statemanager.rb
Gosuplus-1.0.1 lib/Gosuplus/statemanager.rb