I’m atempting to get a scroller game that the player rotates and moves around the map. I sadly can’t get the rotation correct. I don’t want to dump much code, but here’s a paste bin using a tutorial’s code but modified.
To get your rotation working, you need to change two things:
Currently you are getting your difX, difY relative to the centre of the screen, not the player. This will throw you calculations off if you are trying to get the player to look at the mouse.
Secondly, you will need to remember to pass OpenGL the negative of your rotation, as rotating the camera backwards gives the effect of moving everything forward, and vice versa.
–
As a suggestion: At the moment, your player is arbitrarily shifted by adding 400 to translate and vertex calls. I’d suggest creating a separate variables/classes to store information for each of these: Objects(like your player), and the camera. This should reduce confusion when writing your transformations.