Sha256: 277fd6125ec7f102f08ec0c383e75c21007e67e36370d48de12c65685232f5a7

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

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

    def update
      @states[@index].update if @states.size > 0
      self.next if @states[@index].finished
    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
      @index += 1
      @states[@index].on_load
    end

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

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

      @states << state
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Gosuplus-1.0.261 lib/Gosuplus/statemanager.rb