keyevents
E. Almqvist 3 years ago
parent 069b3e910b
commit 512e3fcde1
  1. 8
      src/app.rb
  2. 8
      src/lib/physobj.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[1.2, 0]
@world.controller = ply
cube2 = PhysCube.new("Beta", self, 8, 8)
@ -65,7 +65,7 @@ class Window < Gosu::Window
sol = Planet.new("Sol", self, 0xff_ffffaa, 1e2, 15, 1)
sol.pos = Vector[800, 450]
planet = Planet.new("Planet", self, 0xff_cccccc, 1e1, 8, 1)
planet = Planet.new("Planet", self, 0xff_cccccc, 1e-1, 8, 1)
planet.pos = Vector[800, 450 + 300]
planet.vel = Vector[-2, 0]
planet.show_info = true
@ -74,11 +74,11 @@ class Window < Gosu::Window
sol.orbit(sol_orbiters)
@world.planets << sol
#@world.planets << planet
@world.planets << planet
@world.physobjs << ply
@world.physobjs << cube2
#@world.physobjs << planet
@world.physobjs << planet
@world.freeze = false
# self.mainmenu.show = false

@ -21,7 +21,6 @@ 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
@ -47,15 +46,14 @@ class PhysObj
end
end
def render_path(x_offset=0, y_offset=0)
def render_path(x_offset=0, y_offset=0, color=0xaa_ccccff)
@saved_pos.each do |pos|
Gosu.draw_rect(pos[0] + x_offset, pos[1] + y_offset, 1, 1, Gosu::Color.argb(0xaa_ccccff))
Gosu.draw_rect(pos[0] + x_offset, pos[1] + y_offset, 1, 1, Gosu::Color.argb(color))
end
end
def inspect
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"
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))

Loading…
Cancel
Save