Camera System

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
ShaDoW
Prole
Posts: 4
Joined: Mon Jan 10, 2011 8:39 am

Camera System

Post by ShaDoW »

Hey everyone, I finally decided to sign up to the forums after much lurking. I've been using Love for some weeks now and I'm enjoying it very much. I've been working on a classic RPG and a small platformer game involving lovely cats, though I've stumbled upon my first real problem. How does one implement a camera system in Love?

My previous attempt for my platformer which uses love.physics was using love.graphics.translate inside the love.draw function which moves the level when the player goes left or right. I found this causes some issues though, like when using a tilemap, little lines will jitter between the tile edges. So I found this solution to be kind of a hack, looking through the source of other Love games, I couldn't find anyone else using this solution either.

I suppose I don't really want to move the world in the first place, not when using physics, just the view.

How does one manipulate the love.draw function using a camera which follows the player through a level? I hope my description isn't too vague. Thanks!
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Camera System

Post by vrld »

Hello and welcome to the forums!
Your approach of using love.graphics.translate inside love.graphics.draw is in fact the right solution. From a theoretical point of view, there is no difference in moving the world around a viewpoint or moving a viewpoint around in a world. In practice, there isn't even such a thing as a view.
A camera class would just be an abstraction of the moving, scaling and rotating that is necessary to view at a certain portion of the screen.
Lucky for you, there are already some camera classes out there. The two of which I am aware of are: hump's camera class is more lightweight (around 1/4 the code) than Pässions, that's only natural, since Kikito's version is embedded in a full blown game engine.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
ShaDoW
Prole
Posts: 4
Joined: Mon Jan 10, 2011 8:39 am

Re: Camera System

Post by ShaDoW »

Many thanks for the warm welcome and your help! It's much appreciated.

Yeah, I understand what you mean; a camera is just an abstraction. My crude method of love.graphics.translate worked in some sense and it seemed perfectly logical to do things this way at the time, but it didn't seem perfect. I actually looked through your implementation within hump last night but decided I wanted to inform myself about this subject first. :)

Thanks again, I'm going to try humping your camera class tonight.
ShaDoW
Prole
Posts: 4
Joined: Mon Jan 10, 2011 8:39 am

Re: Camera System

Post by ShaDoW »

Just an update, after I came home from work I gave your camera library a try. I'm glad to say that it works great! Great job on the documentation of your library as well. :)
Post Reply

Who is online

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