Public Group

#### 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 6083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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 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 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 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 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);

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 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,

ps, how about the formula to make the ship go round and round and round..?

##### 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!!!

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 15
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633004
• Total Posts
3009840
• ### Who's Online (See full list)

There are no registered users currently online

×