Minor bug fix

pull/1/head
E. Almqvist 3 years ago
parent 960343f33c
commit 800effc14f
  1. 10
      app.rb
  2. 10
      physobj.rb

@ -86,12 +86,12 @@ class Window < Gosu::Window
end
def draw
if( @controller != nil && @controller.class == Player ) then
if( @controller != nil ) then
@camera = Vector[self.width/2, self.height/2] - @controller.pos
@font.draw_text(@controller.debug_string, 0, 32, 1, 1.0, 1.0, Gosu::Color::WHITE)
end
camx, camy = @camera[0], @camera[1]
# camx, camy = 0, 0
p @camera
@font2.draw_text("Frozen: #{@freeze}", 0, 0, 1, 1.0, 1.0, Gosu::Color::WHITE)
@ -127,9 +127,10 @@ sol = Planet.new("Sol", window, 0xff_ffffaa, 1e2, 15, 1)
sol.pos = Vector[800, 450]
planet = Planet.new("Planet", window, 0xff_cccccc, 1e1, 8, 1)
planet.pos = Vector[200, 150]
planet.pos = Vector[800, 450 + 300]
planet.vel = Vector[-2.5, 0]
planet.show_info = true
window.controller = planet
sol_orbiters = [cube, cube2, planet]
sol.orbit(sol_orbiters)
@ -141,5 +142,4 @@ window.physobjs << cube
window.physobjs << cube2
window.physobjs << planet
window.controller = planet
window.show

@ -139,10 +139,12 @@ class Planet < PhysObj
def orbit(physobjs)
if( !self.world.freeze ) then
physobjs.each do |obj|
grav_vec = self.calculate_gravity_vector(obj)
obj.accel_vecs[self.name] = grav_vec
obj.apply_accel_vecs
obj.parent_orbit = self
if( self != obj ) then
grav_vec = self.calculate_gravity_vector(obj)
obj.accel_vecs[self.name] = grav_vec
obj.apply_accel_vecs
obj.parent_orbit = self
end
end
end
end

Loading…
Cancel
Save