I'm attempting to construct a propulsion system for a physics sprite which will do nothing other than provide a force to push the object from the back to the front - think ship engines.
What it should not do is articulate 'direction', that function is handled elsewhere.
My problem is that the SetSpritePhysicsForce and SetSpritePhysicsImpulse functions 'both' have vx and vy parameters which dictate that the force itself pushes up/down/left/right depending on the positive/negative/zero values and the magnitude is determined by the size of the numbers (vectors). Unfortunately for me, it sets direction.
All I want is the push, not the direction...
Has anyone worked this out elsewhere?
I've done this before when manually articulating the directional values but it's really spit and duct tap ... and I can't do that at this stage.
` **** EngageShipPropulsion()
Function EngageShipPropulsion(angle#)
// Establish Ship heading angle ranges, corresponding propulsion force directions (Forward and reverse)
if angle# < -70 and angle# > -135 ` Up
ship.vx = ZERO
ship.vy = -ship.throttle#
ship.rvx = ZERO
ship.rvy = ship.throttle#
screen.viewOffsetIncrementX# = 0
screen.viewOffsetIncrementY# = -0.5
ship.heading$ = d_UP
elseif angle# > 70 and angle# < 130 ` Down
ship.vx = ZERO
ship.vy = ship.throttle#
ship.rvx = ZERO
ship.rvy = -ship.throttle#
screen.viewOffsetIncrementX# = 0
screen.viewOffsetIncrementY# = 0.5
ship.heading$ = d_DOWN
elseif angle# > 150 and angle# > -150 ` Left
ship.vx = -ship.throttle#
ship.vy = ZERO
ship.rvx = ship.throttle#
ship.rvy = ZERO
screen.viewOffsetIncrementX# = -0.5
screen.viewOffsetIncrementY# = 0
ship.heading$ = d_LEFT
elseif angle# > -45 and angle# < 45 ` Right
ship.vx = ship.throttle#
ship.vy = ZERO
ship.rvx = -ship.throttle#
ship.rvy = ZERO
screen.viewOffsetIncrementX# = 0.5
screen.viewOffsetIncrementY# = 0
ship.heading$ = d_RIGHT
elseif angle# <= -45 and angle# >= -70 ` Top-Right
ship.vx = ship.throttle#
ship.vy = -ship.throttle#
ship.rvx = -ship.throttle#
ship.rvy = ship.throttle#
screen.viewOffsetIncrementX# = 0.5
screen.viewOffsetIncrementY# = -0.5
ship.heading$ = d_TOP_RIGHT
elseif angle# <= -130 and angle# >= -180 ` Top-Left
ship.vx = -ship.throttle#
ship.vy = -ship.throttle#
ship.rvx = ship.throttle#
ship.rvy = ship.throttle#
screen.viewOffsetIncrementX# = -0.5
screen.viewOffsetIncrementY# = -0.5
ship.heading$ = d_TOP_LEFT
elseif angle# <= 90 and angle# >= 45 ` Bottom-Right
ship.vx = ship.throttle#
ship.vy = ship.throttle#
ship.rvx = -ship.throttle#
ship.rvy = -ship.throttle#
screen.viewOffsetIncrementX# = 0.5
screen.viewOffsetIncrementY# = 0.5
ship.heading$ = d_BOTTOM_RIGHT
elseif angle# <= 180 and angle# >= 90 ` Botom-Left
ship.vx = -ship.throttle#
ship.vy = ship.throttle#
ship.rvx = ship.throttle#
ship.rvy = -ship.throttle#
screen.viewOffsetIncrementX# = -0.5
screen.viewOffsetIncrementY# = 0.5
ship.heading$ = d_BOTTOM_LEFT
endif
` **** Create the Physics Force to move the ship - place force directly behind back of the ship ******************************************
CheckCurrentShipState()
x# = -(ship.width#/2.0)*(Cos(angle#))+ship.absCtrX# ` Start from the absolute center of the ship,
y# = -(ship.width#/2.0)*(Sin(angle#))+ship.absCtrY# ` go straight back 1/2 width & 1/2 height to place force pt.
if (ship.reverseEngines = FALSE) ` Engines Forward
SetSpritePhysicsImpulse(ship.sprID, x#, y#, ship.vx, ship.vy)
elseif (ship.reverseEngines = TRUE) ` Engines Reverse
SetSpritePhysicsImpulse(ship.sprID, x#, y#, ship.rvx, ship.rvy)
endif
EndFunction
----
From the Desk of Prof Versaggi ...