Class: SpriteKit::Scene

Inherits:
Object
  • Object
show all
Defined in:
mygame/lib/sprite_kit/scene.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scene_manager) ⇒ Scene

Returns a new instance of Scene.



7
8
9
10
# File 'mygame/lib/sprite_kit/scene.rb', line 7

def initialize(scene_manager)
  @scene_manager = scene_manager
  @draw_buffer = DrawBuffer.new
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def args
  @args
end

#audioObject

Returns the value of attribute audio.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def audio
  @audio
end

#draw_bufferObject

Returns the value of attribute draw_buffer.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def draw_buffer
  @draw_buffer
end

#eventsObject

Returns the value of attribute events.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def events
  @events
end

#inputsObject

Returns the value of attribute inputs.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def inputs
  @inputs
end

#keyboardObject

Returns the value of attribute keyboard.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def keyboard
  @keyboard
end

#mouseObject

Returns the value of attribute mouse.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def mouse
  @mouse
end

#outputsObject

Returns the value of attribute outputs.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def outputs
  @outputs
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def state
  @state
end

#top_layerObject

Returns the value of attribute top_layer.



5
6
7
# File 'mygame/lib/sprite_kit/scene.rb', line 5

def top_layer
  @top_layer
end

Instance Method Details

#calcObject



40
41
# File 'mygame/lib/sprite_kit/scene.rb', line 40

def calc
end

#drawObject



57
58
59
60
61
62
63
64
65
66
# File 'mygame/lib/sprite_kit/scene.rb', line 57

def draw
  render_top_layer
  GTK.warn_array_primitives!

  GTK.framerate_diagnostics_primitives.map.with_index do |primitive, index|
    primitive.y = 1 + index * 16
  end

  @draw_buffer.flush
end

#inputObject



37
38
# File 'mygame/lib/sprite_kit/scene.rb', line 37

def input
end

#renderObject



43
44
# File 'mygame/lib/sprite_kit/scene.rb', line 43

def render
end

#render_top_layerObject



46
47
48
49
50
51
52
53
54
55
# File 'mygame/lib/sprite_kit/scene.rb', line 46

def render_top_layer
  # Goes on top of everything.
  @top_layer.w = Grid.w
  @top_layer.h = Grid.h

  @outputs[:top_layer].w = @top_layer.w
  @outputs[:top_layer].h = @top_layer.h
  @outputs[:top_layer].transient!
  @draw_buffer.primitives << @top_layer
end

#tick(args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'mygame/lib/sprite_kit/scene.rb', line 12

def tick(args)
  @args = args
  @outputs = args.outputs
  @inputs = args.inputs
  @state = args.state
  @audio = args.audio
  @events = args.events
  @gtk = args.gtk
  @mouse = args.inputs.mouse
  @keyboard = args.inputs.keyboard
  @top_layer = {
    w: Grid.w,
    h: Grid.h,
    x: 0,
    y: 0,
    path: :top_layer,
  }
  @draw_buffer.outputs = @outputs

  input
  calc
  render
  draw
end