class Gosuplus::StateManager

Public Class Methods

new(window) click to toggle source
# File lib/Gosuplus/statemanager.rb, line 3
def initialize(window)
  @states = []
  @index = 0
end

Public Instance Methods

add(state) click to toggle source
# File lib/Gosuplus/statemanager.rb, line 33
def add(state)
  state.on_load unless @states.size > 0

  @states << state
end
draw() click to toggle source
# File lib/Gosuplus/statemanager.rb, line 13
def draw
  @states[@index].draw if @states.size > 0
end
handle_input(key, type) click to toggle source
# File lib/Gosuplus/statemanager.rb, line 17
def handle_input(key, type)
  @states[@index].handle_input(key, type) if @states.size > 0
end
next() click to toggle source
# File lib/Gosuplus/statemanager.rb, line 21
def next
  @states[@index].on_exit
  @index += 1
  @states[@index].on_load
end
previous() click to toggle source
# File lib/Gosuplus/statemanager.rb, line 27
def previous
  @states[@index].on_exit
  @index -= 1
  @states[@index].on_load 
end
update() click to toggle source
# File lib/Gosuplus/statemanager.rb, line 8
def update
  @states[@index].update if @states.size > 0
  self.next if @states[@index].finished
end