🔒 Locked
Problem With Angles
Advertisement
Original Post
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.
Hmm, ive tried that and I must be doing something wrong. Here's the line of code I am using:
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.
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.
Ahhh, I bet that's what I'm doing wrong. Let me try that out and I'll let you know what happens. Thanks!
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:
1 degree = 0.0174532925 Radians
Just as reference for others in the future:
1 degree = 0.0174532925 Radians
Quote:
#define fPI 3.14156f
#define fDEG2RAD(a) ((a)*fPI/180.0f)
#define fRAD2DEG(a) ((a)*180.0f/fPI)
#define dPI 3.14156
#define dDEG2RAD(a) ((a)*dPI/180.0)
#define dRAD2DEG(a) ((a)*180.0/dPI)
If you used 180, it would cast the answer to an integer.
Does this mean I'm a finally a guru? =)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement