Minor refactor

pull/1/head
E. Almqvist 3 years ago
parent bb537ec0cb
commit 94436e47bf
  1. 16
      app.rb
  2. 28
      physobj.rb

@ -14,7 +14,7 @@ class Window < Gosu::Window
@physobjs = physobjs
@planets = planets
@font = Gosu::Font.new(self, Gosu::default_font_name, 14)
@font = Gosu::Font.new(self, Gosu::default_font_name, 18)
@font2 = Gosu::Font.new(self, Gosu::default_font_name, 20)
@fonts = {
@ -63,14 +63,12 @@ class Window < Gosu::Window
# end
def update
if( !@freeze ) then
@physobjs.each do |obj|
obj.physics
end
@planets.each do |planet|
planet.orbit(@physobjs)
end
@physobjs.each do |obj|
obj.physics
end
@planets.each do |planet|
planet.orbit(@physobjs)
end
end

@ -21,19 +21,21 @@ class PhysObj
end
def tick
if( @accel.magnitude != 0 ) then
@vel += @accel
end
if( @vel.magnitude != 0 ) then
@pos += @vel
end
@x, @y = @pos[0], @pos[1]
@angle %= 360
@saved_pos << @pos
while(@saved_pos.length > MAX_PATH_TRACK_POINT) do
@saved_pos = @saved_pos[1..-1]
if( !world.freeze ) then
if( @accel.magnitude != 0 ) then
@vel += @accel
end
if( @vel.magnitude != 0 ) then
@pos += @vel
end
@x, @y = @pos[0], @pos[1]
@angle %= 360
@saved_pos << @pos
while(@saved_pos.length > MAX_PATH_TRACK_POINT) do
@saved_pos = @saved_pos[1..-1]
end
end
end

Loading…
Cancel
Save