Advertisement

hi, can you give me the formula, i would like to have a wave-like movement of my

Started by February 23, 2002 01:34 AM
10 comments, last by mickey 22 years, 10 months ago
spaceship, so it''ll be something like this... > > > > > > > > > > > > > there... that''s the movement of my ship, i want it like that but instaed of horizontal, i will do it vertically, thanks!
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Ship.y = Ship.y + sin(c)

where c is a counter for -Inf to +Inf
one cycale is equ to Pi * 2 ( 6.28 )

hope that helps

-Ian
-VBLimitsSorry about the Spelling..
Advertisement
hi! can i ask for more help? it seems i can't figure it out i used to move my ship from top to bottom like this...

ship.y += velX * (tickDiff / 1000.0f)

now, how will i use put in the formula there? thanks!!!

i tried doing this hehe....

ship.y += sin(3.14 * 2 * 6.28 * velX * (tickDiff / 1000.0f)

thanks again!




Edited by - mickey on February 23, 2002 5:52:32 AM
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
did you notice you are using x velocity for y?

I think this will work

ship.y += (velY * (tickDiff/1000.0f)) * sin(c);

You need to pass a double to sin because sin uses radians. It will return a value from -1 to 1.
evilclown, oh that was just a typo error here hehe sorry, i''m sorry clown but i uhh.. plz.. tell me exactly the values i will put in c on sin(c)... thanks!!!
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
c can be any value you like
if you have a graphing calc then graphe this x1=sin(x)
x=-Inf to +Inf
where Inf = infinaty
to get one full sin wave out of size start at 0 and goto 2*Pi (e.g. 6.28 )

-Ian

Edit: Missed Value

Edited by - VBLimits on February 23, 2002 5:58:55 PM
-VBLimitsSorry about the Spelling..
Advertisement
hey guys i did it! My problem though is that I only changed the ship''s Y value, i should also changed the X value;

i used this, pls see if it''s correct,

double pi = 3.14;
double ValueX = 0.015, ValueY = 0.001;

ValueX += 0.015;
ValueY += 0.001;

alien.X += alien.VelX * (dwTickDiff / 1000.0f) * sin(ValueX * pi);
alien.Y += alien.VelY * (dwTickDiff / 1000.0f) * sin(ValueY * pi);

then everytime i increment the ValueX and ValueY, so the sin changes, is that why you guys trying to explain?

oh, one more thing, how do i do now when i want my ship to go round in circle? and how do i actually control these angles? any link to a good game math?


http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
If I understand what you are trying to do right, try this:

alien.X += alien.VelX * (dwTickDiff / 1000.0f);
alien.Y += alien.VelY * (dwTickDiff / 1000.0f) * sin(ValueY * pi);

Here''s some math links:

http://rookscape.com/vbgaming/tutorials.php (written in vb but might be what you''re looking for)

http://www.gamedev.net/reference/list.asp?categoryid=28
evilclown: whoa, that thing makes my ship goes off the screen, i should also use a sin on the x positin of the ship, if i take of the sin, it will not work properly,

anway, thanks for the link!

ps, how about the formula to make the ship go round and round and round..?
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
evilclown, you''re vb link helped a bit, but i still need more information about the use of sines and what kind of values to put there to effectively get the angles that i want, do you have any other link? i read the optimizing your trigo functions there

hmm.. maybe you can explain a bit about sines? why not Cosine anyways? they both divides by the hypotenuse right?

thanks so much guys!!!
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

This topic is closed to new replies.

Advertisement