Player controlls

pull/1/head
E. Almqvist 3 years ago
parent 08e70ec3e4
commit 2b38961f49
  1. 18
      app.rb
  2. 12
      physobj.rb

@ -46,6 +46,22 @@ class Window < Gosu::Window
end
end
# def button_up?(id)
# super id
#
# if( @controller != nil ) then
# @controller.button_up?(id)
# end
# end
#
# def button_down?(id)
# super id
#
# if( @controller != nil ) then
# @controller.button_down?(id)
# end
# end
def update
if( !@freeze ) then
@physobjs.each do |obj|
@ -95,7 +111,7 @@ window.controller = cube
cube2 = PhysCube.new("Beta", window, 8, 8)
cube2.pos = Vector[800, 450 + 300]
cube2.vel = Vector[-2.5, 0]
cube2.vel = Vector[-1.24, 0]
planet.orbit([cube, cube2])

@ -159,6 +159,12 @@ class Player < PhysCube
end
def button_up(id)
end
def button_up?(id)
end
def button_down(id)
if( id == Gosu::KbSpace ) then
@engine = !@engine
end
@ -172,6 +178,10 @@ class Player < PhysCube
end
end
def button_down(id)
def button_down?(id)
end
private def debug_string
return "\n#{self.name}\nVel: #{self.vel.magnitude.round(1)} #{self.vel.round(4)}\nAccel: #{self.accel.magnitude.round(4)} #{self.accel.round(4)}\nPos: #{self.pos.round(4)}\nAngle: #{self.angle.round(1)} deg\nEngine: #{self.engine}\nThrust: #{self.thrust}\n"
end
end

Loading…
Cancel
Save