# Problem With Angles

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

## Recommended Posts

Hey guys, I've got a rather easy question for all of you veterans out there. I finally got all of my classes set up for my pong game but I am having a tough time working out the equations to effectively pass an angle to a function and have it generate the change in x and y (slope I presume) for my vertices. I bought a book on game physics, but it starts out a little further than this basic concept. Couldnt find anything on google either about converting angles to slope. Any help I can get would be greatly appreciated. Thanks everyone.

##### Share on other sites
where Ø is the angle
∆X=cos(Ø)∆Y=sin(Ø)

##### Share on other sites
Hmm, ive tried that and I must be doing something wrong. Here's the line of code I am using:

Rect->Set_Position(Rect->myX plus (float) cos(90), Rect->myY plus (float) sin(90));

Change the word plus to a plus sign, for some reason it filtered that character. If I understand this correctly, depending on which way the coordinates of the screen are oriented with angles, it should go either straight up, down, left or right. It actually did none of those, it went in sort of a south south west angle. I could be doing something completely wrong. Oh BTW, the Set_Position function takes two arguements, x and y and in that order. This just sets the position of the object. Thanks guys.

##### Share on other sites
c++ math functions work with radians, not degrees. (I assume this is c++.)

Also, although +'s are for some reason filtered in the preview, they actually show up in the post :-)

##### Share on other sites
Ahhh, I bet that's what I'm doing wrong. Let me try that out and I'll let you know what happens. Thanks!

##### Share on other sites
That works, awesome! I tried finding some documentation on the cos and sin methods but was short on information. I was about to pull my hair out. Thanks a million.

Just as reference for others in the future:

macros suck

##### Share on other sites
Although I don't see any way that specific macro could be bad (I'm sure the gurus will find some) I prefer to multiply by:

##### Share on other sites
Quote:

If you used 180, it would cast the answer to an integer.
Does this mean I'm a finally a guru? =)

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999976
×