How to properly rotate the camera

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
idkfa
Prole
Posts: 1
Joined: Sat Apr 08, 2017 5:46 pm

How to properly rotate the camera

Post 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.
Attachments
shmup.love
(66.25 KiB) Downloaded 143 times
This should illustrate the problem.
This should illustrate the problem.
sidebyside.JPG (186.71 KiB) Viewed 2989 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: How to properly rotate the camera

Post 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).
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: How to properly rotate the camera

Post by Sheepolution »

Check out the library gamera
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests