how to rotate a quad in OpenGL (2D)

Started by
33 comments, last by graveyard filla 19 years, 10 months ago
hey unliterate, thanks alot!! that was the problem, i wasnt converting to degree's (i didnt know the forumla gave me radians.. on the net i read it gave degree's)

but im still having one more problem, this time ill provide pictures..

first, my rocket looks like this:

now, if im shooting at the enemy from the left side, everything is fine! it looks great:


BUT, if im shooting at the enemy from the right side, the angle appears to be correct, but the texture/quad is flipped!


do you know why this is happening, and how i could stop it?


also, if im on the left side of the enemy, the degree's will always be between 90 (standing directly above) and -90 (standing directly below). it will look fine. but as soon as i step on the right side of the enemy, it looks backwards like this. in fact, when im on the right side of the enemy, the degree are -90 (directly at the top of the enemy) and 90 (directly below the enemy)

so why are my degree's always between -90 and 90? and how would i go about "flipping" the quad when im shooting from the right side? thanks for anymore help!!

[edited by - graveyard filla on June 13, 2004 6:26:19 PM]
FTA, my 2D futuristic action MMORPG
Advertisement
hm, you may try, rather than angle+=pi , angle=pi-angle. for the other angle measure. but im not sure if i completely understand what the current problem is.

(replace pi with 180º if needed of course. however your doing it.)

[edited by - unliterate on June 13, 2004 6:33:26 PM]

[edited by - unliterate on June 13, 2004 6:34:36 PM]
as for the range, i meant the range of the arc functions is 180, ( 90 - -90 =180 ), for arc sine and arc tangent, thatll be bewtween -90 and 90, and for arc cosine, 0 and 180. i dont know your background on trig but, a negative angle is the same as that angle + 360. (there are an infinite number of angle measures for any given angle representation, ie: -90,270,630,etc).
actually, everything IS working fine.. i stupidly forgot the angle+= before the 3.14...

now it all works great!! thanks a lot man!! if only now i understood half this stuff

also, you said using arccos or arcsin would be faster if i am calculating the distance... i AM calcing the distance (to find the velocity the rocket should go).. so how would it go using those then? thanks again for all your help!!
FTA, my 2D futuristic action MMORPG
heheh, i just relised it wouldnt be any faster at all, i figured because arcsine would be (DifY/distance) thats just one less subtraction to do, but the DifX would still be needed for the range corrector. not to mention it'd have been such a negligble performance increase.

oh, and happy to help, ive got a math final comming up so its good to practice.


[edited by - unliterate on June 13, 2004 6:54:02 PM]

This topic is closed to new replies.

Advertisement