Class: State

Inherits:
Object show all
Defined in:
lib/moon/packages/std/state.rb

Overview

core/state.rb

Base class for all States

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ State

Returns a new instance of State.

Parameters:

  • engine (Void)

17
18
19
20
21
# File 'lib/moon/packages/std/state.rb', line 17

def initialize(engine)
  @engine = engine
  @started = false
  @state_manager = nil
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine


10
11
12
# File 'lib/moon/packages/std/state.rb', line 10

def engine
  @engine
end

#state_managerMoon::StateManager

Returns:


13
14
15
# File 'lib/moon/packages/std/state.rb', line 13

def state_manager
  @state_manager
end

#ticksObject (readonly)

Returns the value of attribute ticks


7
8
9
# File 'lib/moon/packages/std/state.rb', line 7

def ticks
  @ticks
end

Instance Method Details

#initVoid

Init use this instead to initialize a State

Returns:

  • (Void)

79
80
81
# File 'lib/moon/packages/std/state.rb', line 79

def init  #

end

#invokeObject

Used when the State is just added to the Stack


31
32
33
# File 'lib/moon/packages/std/state.rb', line 31

def invoke
  reset
end

#pauseObject

Gets called when the state is put on pause and a new state is loaded on top of it


98
99
100
# File 'lib/moon/packages/std/state.rb', line 98

def pause  #

end

#post_renderVoid

Returns:

  • (Void)

144
145
146
# File 'lib/moon/packages/std/state.rb', line 144

def post_render  #

end

#post_update(delta) ⇒ Object

Parameters:


124
125
126
# File 'lib/moon/packages/std/state.rb', line 124

def post_update(delta)
  #
end

#pre_renderVoid

Returns:

  • (Void)

130
131
132
# File 'lib/moon/packages/std/state.rb', line 130

def pre_render  #

end

#pre_update(delta) ⇒ Object

Parameters:


110
111
112
# File 'lib/moon/packages/std/state.rb', line 110

def pre_update(delta)
  #
end

#renderVoid

Per frame render function, called by moon called when the state is intended to be rendered to screen

Returns:

  • (Void)

138
139
140
# File 'lib/moon/packages/std/state.rb', line 138

def render  #

end

#resetself

Returns:

  • (self)

37
38
39
40
41
42
# File 'lib/moon/packages/std/state.rb', line 37

def reset
  @ticks = 0
  @started = false
  init
  self
end

#resumeObject

Gets called when the state resumes


104
105
106
# File 'lib/moon/packages/std/state.rb', line 104

def resume  #

end

#screenMoon::Screen

Alias for engine.screen

Returns:


25
26
27
# File 'lib/moon/packages/std/state.rb', line 25

def screen
  @engine.screen
end

#startObject

start


85
86
87
# File 'lib/moon/packages/std/state.rb', line 85

def start  #

end

#step(delta) ⇒ Object

Parameters:


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/moon/packages/std/state.rb', line 46

def step(delta)
  unless @started
    start
    @started = true
  end  # game logic

  update_step delta  # rendering

  render_step  #

  @ticks += 1
end

#terminateObject

Gets called when we close the state


91
92
93
# File 'lib/moon/packages/std/state.rb', line 91

def terminate  #

end

#update(delta) ⇒ Void

Per frame update function, called by moon

Parameters:

Returns:

  • (Void)

118
119
120
# File 'lib/moon/packages/std/state.rb', line 118

def update(delta)
  #
end