Projoectile along an angle

Started by
12 comments, last by haegarr 18 years, 4 months ago
Tank.rar

you can see it for yourself, I'm really baffled heh. I just read the article about motion in 2D/3D space, which basically boiled down to the same concepts youve been talking about and what I've got down in code.
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)
Advertisement
As I've said: You're using degree where radians were appropriate. Look here:

You compute the turret angle by increasing/decreasing Tank::Turret_Angle. This variable is defined in degrees. You correctly overhand this to glRotate inside Tank::Draw().

_But_ you also create new bullets by overhanding the degree value:
bullet.insert(bullet.end(), 1, Bullet(X + 24, Y - 111, Turret_Angle));
Then, in the constructor, you compute
vx = cos(a);
vy = sin(a);
directly from it, so that in fact
vx = cos(Turret_Angle);
vy = sin(Turret_Angle);
stands there.

However, the argument of sin and cos are to be measured in _radians_. So it must be
       a *= 3.14159f/180.0f;       vx = cos(a);        vy = sin(a); 

instead!!
yep, you're right. but where does it say that those functions use radians? I was reading the header front to back looking for clues, it didn't even say that in a textbook i have ABOUT the standard libraries in the math section.

but the important thing is it works, and that kicks are. next stop.. collisions :<
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)
Don't know. I'm using linux, and in such cases I type a "man cos" manual page command in the shell. That says: "The cos() function returns the cosine of x, where x is given in radians."

This topic is closed to new replies.

Advertisement