Class: FelFlame::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/felflame.rb,
lib/felflame/stage_manager.rb

Overview

Stores Scenes which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.scenesArray<Scene>

Contains all the Scenes added to the Stage

Returns:

  • (Array<Scene>)


58
59
60
# File 'lib/felflame/stage_manager.rb', line 58

def scenes
  @scenes ||= []
end

Class Method Details

.add(*scenes_to_add) ⇒ Boolean

Add any number of Scenes to the Stage

Returns:

  • (Boolean)

    true



11
12
13
14
15
16
17
18
# File 'lib/felflame/stage_manager.rb', line 11

def add(*scenes_to_add)
  self.scenes |= scenes_to_add
  scenes_to_add.each do |scene|
    self.systems |= scene.systems
  end
  systems.sort_by!(&:priority)
  true
end

.callBoolean

Executes one frame of the game. This executes all the Systems in the Scenes added to the Stage. Systems that exist in two or more different Scenes will still only get executed once.

Returns:

  • (Boolean)

    true



51
52
53
54
# File 'lib/felflame/stage_manager.rb', line 51

def call
  systems.each(&:call)
  true
end

.clearBoolean

Clears all Scenes that were added to the Stage

Returns:

  • (Boolean)

    true



43
44
45
46
47
# File 'lib/felflame/stage_manager.rb', line 43

def clear
  systems.clear
  scenes.clear
  true
end

.remove(*scenes_to_remove) ⇒ Boolean

Remove any number of Scenes from the Stage

Returns:

  • (Boolean)

    true



22
23
24
25
26
# File 'lib/felflame/stage_manager.rb', line 22

def remove(*scenes_to_remove)
  self.scenes -= scenes_to_remove
  update_systems_list
  true
end