• Advertisement

Archived

This topic is now archived and is closed to further replies.

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

This topic is 5805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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..?

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
Do you know what the unit circle is? It''s a circle and it''s center is the origin (0, 0). It has a radius of 1. Now you can use cosine and sine to find the coordinates of the point (1,0) rotated on the circle.

So if you want to rotate (1, 0) 90 degrees you would do

x = cos(90)
x = 0

y = sin(90)
y = 1

so the new coordinates would be (0, 1)

that probably doesn''t make sense. This link will explain it http://www.rookscape.com/vbgaming/tutBK.php

Share this post


Link to post
Share on other sites

  • Advertisement