Class: Ruck::GLApp::RuckSketch

Inherits:
Object
  • Object
show all
Includes:
GLApp
Defined in:
lib/ruck/glapp/glapp.rb

Instance Method Summary collapse

Constructor Details

#initialize(filenames) ⇒ RuckSketch

Returns a new instance of RuckSketch.



88
89
90
# File 'lib/ruck/glapp/glapp.rb', line 88

def initialize(filenames)
  @filenames = filenames
end

Instance Method Details

#drawObject



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ruck/glapp/glapp.rb', line 103

def draw
  @events.each do |pair|
    ev, queue = pair
    SHREDULER.raise_event ev, queue
  end
  @events = []

  SHREDULER.catch_up # execute shreds whose time came while drawing previous frame

  SHREDULER.raise_event Object.new, :frame
end

#keyboard_down(key, modifiers) ⇒ Object



115
116
117
# File 'lib/ruck/glapp/glapp.rb', line 115

def keyboard_down(key, modifiers)
  @events << [Struct.new(:key).new(key), :key_down]
end

#keyboard_up(key, modifiers) ⇒ Object



119
120
121
# File 'lib/ruck/glapp/glapp.rb', line 119

def keyboard_up(key, modifiers)
  @events << [Struct.new(:key).new(key), :key_up]
end

#mouse_click(button, state, x, y) ⇒ Object



131
132
133
134
135
136
137
# File 'lib/ruck/glapp/glapp.rb', line 131

def mouse_click(button, state, x, y)
  if state == 0
    @events << [Struct.new(:button, :x, :y).new(button, x, y), :mouse_down]
  else
    @events << [Struct.new(:button, :x, :y).new(button, x, y), :mouse_up]
  end
end

#mouse_motion(x, y) ⇒ Object



139
140
141
# File 'lib/ruck/glapp/glapp.rb', line 139

def mouse_motion(x, y)
  @events << [Struct.new(:x, :y).new(x, y), :mouse_move]
end

#setupObject



92
93
94
95
96
97
98
99
100
101
# File 'lib/ruck/glapp/glapp.rb', line 92

def setup
  @filenames.each do |filename|
    SHREDULER.spork(filename) do
      require filename
    end
  end
  @events = []

  SHREDULER.starting
end

#special_keyboard_down(key, modifiers) ⇒ Object



123
124
125
# File 'lib/ruck/glapp/glapp.rb', line 123

def special_keyboard_down(key, modifiers)
  @events << [Struct.new(:key).new(key), :key_down]
end

#special_keyboard_up(key, modifiers) ⇒ Object



127
128
129
# File 'lib/ruck/glapp/glapp.rb', line 127

def special_keyboard_up(key, modifiers)
  @events << [Struct.new(:key).new(key), :key_up]
end