Page 1 of 1

How to properly rotate the camera

Posted: Sat Apr 08, 2017 6:50 pm
by idkfa
Hello everyone, I'm new to Löve (and game development in general), and I'm having some trouble understanding the camera concept properly. Without having some previous knowledge, making one on my own seemed way too complex, so I've searched the wiki and found this. I still couldn't quite understand how everything works, but eventually I've got around it... except for camera rotation.

The rotation is working, but from the topleft corner. My guess is that I need a lg.translante(...) somewhere.
Any idea on how to solve it? I'm a bit lost right now.

Also, if anyone knows a tutorial/explanation on this subject(should I call it 'screen transformation'?), it'd be greatly appreciated.

Re: How to properly rotate the camera

Posted: Sat Apr 08, 2017 7:18 pm
by bartbes
The trick to having rotation (or scale, or shear, etc) applied at a particular pointing is first translating to the point, then doing the operation, then translating back. So in this case love.graphics.translate(x, y), followed by love.graphics.rotate(angle), followed by love.graphics.translate(-x, -y).

Re: How to properly rotate the camera

Posted: Sat Apr 08, 2017 7:58 pm
by Sheepolution
Check out the library gamera