by sorta i mean it obeys the law of inertia. it doesnt take mass into account yet. this only deals with velocity so rotations are the same as normal. i want to convert max velocity to max thrust output in newtons. in other words a ship at full thrust with the max thrust of 100 will produce 100 newtons of force at full throttle. then i can have acceleration rates based on force vs mass. il deal with that later. my current concern is in making flying newtonian playable. so now im focusing on making the nessicary gauges.
also this only works on the player, need to figure out how to deal with physics on a ship by ship basis, so that all ships operate them. im hopping i can tag objects with custom varibles, then its just a matter of loopong through the ships. the other thing is that it breaks the lead indicators, cause im setting the position directly rather than changing the velocity, which doesnt work. could probibly just use wanderers lead code, which ive butchered into my scripts till i wright my own.
anyway heres the code, id advise using a ship set up for 6dof flight (with slide and rear thrust enabled). you can use any ship but youl have to come about to slow down.
#Global Hooks
$GameInit:
[
--[[=============================]]--
--[[======= function defs =======]]--
--[[=============================]]--
setscreenvars = function() --scalers and constants for multi res support
local w = gr.getScreenWidth()
local h = gr.getScreenHeight()
local cx = w/2
local cy = h/2
local wf = 0
local hf = 0
local awh = 0
local hires = false
if w >= 1024 then
wf = w / 1024
hf = h / 768
awh = (wf + hf) / 2
hires = true
else
wf = w / 640
hf = h / 480
awh = ((wf + hf) / 2) * 0.625
hires = false
end
return w,h,cx,cy,wf,hf,awh,hires
end
round = function(number) --rounds to nearest whole number, for some stupid reason, lua doesnt have this function
local W,F = math.modf(number)
if F < 0 then
if F <= -0.5 then W = W - 1 end
else
if F >= 0.5 then W = W + 1 end
end
return W
end
prograderet = function(x,y,vel)
x, y = x*wf, y*hf --round theese, our vector gets jumpy
gr.setColor(72,192,72,222)
gr.drawGradientLine(x + (12*awh), y + (12*awh), x + (6*awh), y + (6*awh) )
gr.drawGradientLine(x - (12*awh), y - (12*awh), x - (6*awh), y - (6*awh) )
gr.drawGradientLine(x - (12*awh), y + (12*awh), x - (6*awh), y + (6*awh) )
gr.drawGradientLine(x + (12*awh), y - (12*awh), x + (6*awh), y - (6*awh) )
vel = tostring(vel)
gr.setColor(128,192,128,222)
gr.drawString(vel, x - (gr.getStringWidth(vel) / 2), y - (2*awh) )
end
w,h,cx,cy,wf,hf,awh,hires = setscreenvars()
]
$Simulation:
[
player = mn.Ships["Alpha 1"]
if player:isValid() then
if lvel == nil then lvel = ba.createVector(0,0,0) end
lvel = lvel + ( player.Physics.VelocityDesired * 0.01 * ba.getFrametime() )
wvel = player.Position + lvel
lmag = lvel:getMagnitude()
lmag = lmag / ba.getFrametime()
gr.drawString( round(lmag), 100 ,100)
Vx,Vy = (wvel + (lvel*lmag) ):getScreenCoords()
player.Position = wvel
end
]
$HUD:
[
if player:isValid() then
if Vx then prograderet( Vx, Vy, round(lmag) ) end
end
]
#End