Bug fixes etc

physics
E. Almqvist 3 years ago
parent 4332f8ba00
commit 604f8f4c09
  1. 8
      src/app.rb
  2. 6
      src/lib/physobj.rb
  3. 8
      src/lib/world.rb

@ -54,7 +54,7 @@ class Window < Gosu::Window
ply.show_info = false
ply.thrust = 0.0075
ply.pos = Vector[800, 450 + 500]
ply.vel = Vector[1, 0]
ply.vel = Vector[0.1, 0]
@world.controller = ply
cube2 = PhysCube.new("Beta", self, 8, 8)
@ -81,7 +81,7 @@ class Window < Gosu::Window
@world.physobjs << planet
@world.freeze = false
self.mainmenu.show = false
# self.mainmenu.show = false
end
def button_up(id)
@ -144,7 +144,7 @@ end
window = Window.new("Hohmann Miner", WINDOW_WIDTH, WINDOW_HEIGHT)
window.fullscreen = WINDOW_FULLSCREEN
window.mainmenu = MainMenu.new(window, true)
# window.mainmenu = MainMenu.new(window, true)
window.start_game
window.show
# window.start_game

@ -21,12 +21,15 @@ class PhysObj
def apply_accel_vecs
summed_vec = Vector.zero(2)
@accel_vecs.each do |planet, vec|
puts "#{@name} # #{planet} : #{vec}"
summed_vec += vec
end
@accel = summed_vec
end
def tick
self.apply_accel_vecs
@x, @y = @pos[0], @pos[1]
@angle %= 360
@ -51,7 +54,8 @@ class PhysObj
end
def inspect
return "\n#{self.name} - #{self.parent_orbit.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\n"
return "\n#{self.name}"
# return "\n#{self.name} - #{self.parent_orbit.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\n"
end
def render(x_offset=0, y_offset=0, color=Gosu::Color.argb(0xaa_2222ff))

@ -1,5 +1,5 @@
class World
attr_accessor :freeze, :physobjs, :planets, :controller, :camera
attr_accessor :freeze, :physobjs, :planets, :controller, :camera, :window
def initialize(seed, window)
@seed = seed
@window = window
@ -29,12 +29,12 @@ class World
def render
if( @controller != nil ) then
self.camera = Vector[self.width/2, self.height/2] - self.controller.pos
@font.draw_text(self.controller.inspect, 0, 32, 1, 1.0, 1.0, Gosu::Color::WHITE)
self.camera = Vector[self.window.width/2, self.window.height/2] - self.controller.pos
self.window.fonts[:normal].draw_text(self.controller.inspect, 0, 32, 1, 1.0, 1.0, Gosu::Color::WHITE)
end
camx, camy = self.camera[0], self.camera[1]
@font2.draw_text("Frozen: #{@freeze}", 0, 0, 1, 1.0, 1.0, Gosu::Color::WHITE)
self.window.fonts[:normal].draw_text("Frozen: #{@freeze}", 0, 0, 1, 1.0, 1.0, Gosu::Color::WHITE)
@physobjs.each do |obj|
obj.render(camx, camy)

Loading…
Cancel
Save