|
|
@ -67,18 +67,18 @@ class Window < Gosu::Window |
|
|
|
sol_orbiters = [cube, cube2, planet] |
|
|
|
sol_orbiters = [cube, cube2, planet] |
|
|
|
sol.orbit(sol_orbiters) |
|
|
|
sol.orbit(sol_orbiters) |
|
|
|
|
|
|
|
|
|
|
|
self.planets << sol |
|
|
|
@world.planets << sol |
|
|
|
self.planets << planet |
|
|
|
@world.planets << planet |
|
|
|
|
|
|
|
|
|
|
|
self.physobjs << ply |
|
|
|
@world.physobjs << ply |
|
|
|
self.physobjs << cube2 |
|
|
|
@world.physobjs << cube2 |
|
|
|
self.physobjs << planet |
|
|
|
@world.physobjs << planet |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def button_up(id) |
|
|
|
def button_up(id) |
|
|
|
super id |
|
|
|
super id |
|
|
|
|
|
|
|
|
|
|
|
if( @world.controller != nil && @world.controller.class == Player ) then |
|
|
|
if( @world && @world.controller ) then |
|
|
|
@world.controller.button_up(id) |
|
|
|
@world.controller.button_up(id) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -90,7 +90,7 @@ class Window < Gosu::Window |
|
|
|
@freeze = !@freeze |
|
|
|
@freeze = !@freeze |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if( @world.controller != nil && @world.controller.class == Player ) then |
|
|
|
if( @world && @world.controller ) then |
|
|
|
@world.controller.button_down(id) |
|
|
|
@world.controller.button_down(id) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -98,7 +98,7 @@ class Window < Gosu::Window |
|
|
|
def button_up?(id) |
|
|
|
def button_up?(id) |
|
|
|
super id |
|
|
|
super id |
|
|
|
|
|
|
|
|
|
|
|
if( @world.controller != nil && @world.controller.class == Player ) then |
|
|
|
if( @world && @world.controller ) then |
|
|
|
@world.controller.button_up?(id) |
|
|
|
@world.controller.button_up?(id) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -106,7 +106,7 @@ class Window < Gosu::Window |
|
|
|
def button_down?(id) |
|
|
|
def button_down?(id) |
|
|
|
super id |
|
|
|
super id |
|
|
|
|
|
|
|
|
|
|
|
if( @world.controller != nil && @world.controller.class == Player ) then |
|
|
|
if( @world && @world.controller ) then |
|
|
|
@world.controller.button_down?(id) |
|
|
|
@world.controller.button_down?(id) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -117,33 +117,13 @@ class Window < Gosu::Window |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private def generate_debug_string(obj) |
|
|
|
|
|
|
|
return "\n#{obj.name}\nVel: #{obj.vel.round(4)} (#{obj.vel.magnitude.round(1)})\nAccel: #{obj.accel.round(4)} (#{obj.accel.magnitude.round(4)})\nPos: #{obj.pos.round(4)}\n" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def draw |
|
|
|
def draw |
|
|
|
@ui.each do |u| |
|
|
|
@ui.each do |u| |
|
|
|
u.render |
|
|
|
u.render |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if( @world.controller != nil ) then |
|
|
|
if( @world ) then |
|
|
|
@world.camera = Vector[self.width/2, self.height/2] - @world.controller.pos |
|
|
|
@world.render |
|
|
|
@font.draw_text(@world.controller.debug_string, 0, 32, 1, 1.0, 1.0, Gosu::Color::WHITE) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
camx, camy = @world.camera[0], @world.camera[1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@font2.draw_text("Frozen: #{@freeze}", 0, 0, 1, 1.0, 1.0, Gosu::Color::WHITE) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@physobjs.each do |obj| |
|
|
|
|
|
|
|
obj.render(camx, camy) |
|
|
|
|
|
|
|
obj.draw_vector(obj.vel, 10, 0xff_ffaaaaa, camx, camy) |
|
|
|
|
|
|
|
obj.draw_vector(obj.accel, 500, 0xff_aaffaa, camx, camy) |
|
|
|
|
|
|
|
obj.render_path(camx, camy) |
|
|
|
|
|
|
|
obj.draw_direction(camx, camy) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@planets.each do |planet| |
|
|
|
|
|
|
|
planet.render(camx, camy) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|