class Physicist::Laboratory::App
Attributes
scientist[RW]
Public Instance Methods
create_scientist(*args)
click to toggle source
# File lib/physicist/laboratory/app.rb, line 85 def create_scientist(*args) CreateScientist.create(*args) end
jump()
click to toggle source
# File lib/physicist/laboratory/app.rb, line 93 def jump JumpScientist.create(scientist_id: scientist_id) end
move_scientist(direction)
click to toggle source
# File lib/physicist/laboratory/app.rb, line 89 def move_scientist(direction) MoveScientist.create(scientist_id: scientist_id, direction: direction) end
press(key)
click to toggle source
# File lib/physicist/laboratory/app.rb, line 65 def press(key) if key == Gosu::KbLeft fire(move_scientist(:left)) elsif key == Gosu::KbRight fire(move_scientist(:right)) end if key == Gosu::KbUp fire(jump) end end
scientist_id()
click to toggle source
# File lib/physicist/laboratory/app.rb, line 97 def scientist_id @scientist_id ||= SecureRandom.uuid end
scientist_view()
click to toggle source
# File lib/physicist/laboratory/app.rb, line 77 def scientist_view ScientistView.where(scientist_id: scientist_id).first || NullScientistView.new end
setup(*)
click to toggle source
# File lib/physicist/laboratory/app.rb, line 36 def setup(*) fire( create_scientist( scientist_id: scientist_id, name: "Bill Bye", title: "Science Guy", position: [0,2], velocity: [0,0] ) ) end
tick()
click to toggle source
# File lib/physicist/laboratory/app.rb, line 48 def tick Scientist.all.each(&:tick) # poll for movement keys... if window.button_down?(Gosu::KbLeft) fire(move_scientist(:left)) elsif window.button_down?(Gosu::KbRight) fire(move_scientist(:right)) end # TODO if window.button_down?(Gosu::KbUp) fire(jump) end end
workspace_view()
click to toggle source
# File lib/physicist/laboratory/app.rb, line 81 def workspace_view WorkspaceView.where(space_id: scientist_view.space_id).first || NullWorkspaceView.new end