Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I know I've already brought this up and kberg helped alot on the subject, thanks, but it's still not working that well in Helian Wars. Here's a snippet of my acceleration code(it's basic code):
if direction(ship) < 10 and direction(ship) > 0 then if y(ship) > -(10-direction(ship)) then y(ship) = y(ship) - 0.5 end if if y(ship) < -(10-direction(ship)) then y(ship) = y(ship) + 0.5 end if if x(ship) < (direction(ship) - 1) then x(ship) = x(ship) + 0.5 end if if x(ship) > (direction(ship) - 1) then x(ship) = x(ship) - 0.5 end if end if
So all that is basically saying is that if the ships sprite is facing anywhere from straight upwards to straight to the right then figure out whether you have to add or subtract 0.5 from the ships current changes in x and/or y.
This sounds all fine to me except in game the movement is really jerky, and it's not because 0.5 is too much of a change.
Can anyone see anything blindingly obvious that I have forgotten about?
Thanks Tycho
------------------ Where the Hell's my roof?
I'm not completely sure what you're doing, but you need to adjust for angle, that is, if you have the ships direction measured as an angle theta, w/ positive theta being counterclockwise from right, then the math to get the appropriate acceleration is: x component of velocity += (magnitude of acceleration) * cos (theta); y component of velocity += (magnitude of acceleration) * sin (theta);
As you can see, I'm used to C/C++, but the math will still work if you translate it into basic.
------------------
(Insert Signature Here)
Quote
Originally posted by Tycho: ** This sounds all fine to me except in game the movement is really jerky, and it's not because 0.5 is too much of a change.
Thanks Tycho **
Need more info... From what I can tell here, this is actually quite wrong. You've set aside an integer between 0 and 10 to determine current direction with a quanta of 0.5. This means you have a total of 20 different directions that an object can face. It might be appropriate to make smaller changes possible.
Analysing what you have, direction is your angle, x and y are your current velocities. You need to convert your direction into whatever format realbasic requires for trig functions.
For degrees it would be angle = (direction(ship) * 36) and for radians it would be angle = (direction(ship) * 0.6283) Then you can use the proper: x(ship) = x(ship) + (some number) * cos(angle) y(ship) = y(ship) + (some number) * sin(angle)
where some number determines how fast the ship will accelerate.
That should work, based on what I can tell from your code. If it doesn't then it will be a manner of tweaking things to fit in with whatever model you've adopted. I would really consider changing the 0.5 quanta though...
------------------ Democracy is like a Reimann sum... www.sfu.ca/~kberg/
Thanks guys.
Sorry about being pretty skimpy on the info, I suck at writing these things.
The sample bit of code was just the code for if your ship was facing anywhere in the first 9 positions from straight up to straight right. The are a total of 36 positions the ship could face in it's whole rotation as an evo ship sprite needs 36 pics.
I was never really good at trig in school but I think I can follow what your trying to say. I'll give it a shot and report back here.