pull/1/head
E. Almqvist 4 years ago
parent 20e3aec04e
commit 0556a9fdde
  1. 34
      physobj.rb
  2. 0
      planet.rb

@ -30,19 +30,17 @@ class PhysObj
@x, @y = @pos[0], @pos[1] @x, @y = @pos[0], @pos[1]
@angle %= 360 @angle %= 360
if( !world.freeze ) then if( @accel.magnitude != 0 ) then
if( @accel.magnitude != 0 ) then @vel += @accel
@vel += @accel end
end
if( @vel.magnitude != 0 ) then if( @vel.magnitude != 0 ) then
@pos += @vel @pos += @vel
end end
@saved_pos << @pos @saved_pos << @pos
if(@saved_pos.length > MAX_PATH_TRACK_POINT) then if(@saved_pos.length > MAX_PATH_TRACK_POINT) then
@saved_pos = @saved_pos[1..-1] @saved_pos = @saved_pos[1..-1]
end
end end
end end
@ -137,14 +135,12 @@ class Planet < PhysObj
end end
def orbit(physobjs) def orbit(physobjs)
if( !self.world.freeze ) then physobjs.each do |obj|
physobjs.each do |obj| if( self != obj ) then
if( self != obj ) then grav_vec = self.calculate_gravity_vector(obj)
grav_vec = self.calculate_gravity_vector(obj) obj.accel_vecs[self.name] = grav_vec
obj.accel_vecs[self.name] = grav_vec obj.apply_accel_vecs
obj.apply_accel_vecs obj.parent_orbit = self
obj.parent_orbit = self
end
end end
end end
end end

Loading…
Cancel
Save