Class: GameState

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/game_states/game_state.rb

Overview

Managing of active game states

Direct Known Subclasses

BuildState, PlayState, QuitState, WelcomeState

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.switch!(next_state) ⇒ Object

Switch active state to next one



4
5
6
7
8
9
10
11
12
# File 'lib/lib/game_states/game_state.rb', line 4

def self.switch!(next_state)
  #puts 'DEBUG: switching to state ' + next_state.to_s

  unless $window.state.nil?
    $window.state.before_end
  end
  $window.state = next_state
  $window.state.after_start
end

Instance Method Details

#after_startObject

What to do just after state gets activated



15
16
# File 'lib/lib/game_states/game_state.rb', line 15

def after_start
end

#before_endObject

What to do just before state gets deactivated



19
20
# File 'lib/lib/game_states/game_state.rb', line 19

def before_end
end

#drawObject



25
26
# File 'lib/lib/game_states/game_state.rb', line 25

def draw
end

#update(button) ⇒ Object



22
23
# File 'lib/lib/game_states/game_state.rb', line 22

def update(button)
end