Page 1 of 2

top down camera

Posted: Wed Sep 05, 2012 12:34 pm
by russ_e
Hello lovely people!

I've been messing around with making my first project in love, using physics, and I've got a physics character moving round by applying forces to it (not sure if this is the best way to do it, but, sod it, it was fun learning).

Now, what i want to do is get the character running round in a level (I've been messing around with the stuff from the tile based tutorials for that). Thing is, I'm new to this kind of thing and I'm stumped as to how to get the camera to lock on to the player character as it moves around the level (i want him center screen).

Do i somehow lock the camera view to the player's position as he moves around (which i have no idea how to do)? Or do i move the world around the player (seems a faff to me)? I'm struggling to figure out where to start on this... Can anyone suggests techniques, tutorials or generally give me a bit of a backrub and slice of tasty cake?

I'm planning to have decent sized levels and i'd like to have all the characters physics driven (enemies, player, spells he casts - is this an insane idea?)

Please excuse the absolute mess of commented out code in there and the general carcrash of code that it is - I've been struggling with the collision checking code, so for this, i cut it and everything to do with it, out :)

Cheers :)

Re: top down camera

Posted: Wed Sep 05, 2012 3:04 pm
by coffee
Hello, welcome, first of all your project is badly packaged. Take attention on that before upload.
Probably for now you could use a camera lib or learn to made one like here (probably most used camera in LOVE)
http://nova-fusion.com/2011/04/19/camer ... he-basics/ (single file, has zoom/scale)

Or you could use those (by oldness order to don't hurt anyone)
vrld, https://github.com/vrld/hump (with zoom/camera but camera have some dependencies)
kikito, https://github.com/kikito/battle-cry/bl ... camera.lua (no zoom/scale, single file)
roland yonaba https://github.com/Yonaba/Love2d-Camera (no zoom/scale, single file)
markandgo https://github.com/markandgo/hump (an updated expanded version of vrld's camera)
Sorry the libs I missed...

Re: top down camera

Posted: Wed Sep 05, 2012 7:50 pm
by qaisjp
I'm new to using Love, but I think drawing to a canvas and then moving the x/y axis of the canvas as per the player position. If the relative position of the player (playerx-canvasx) is less than half the screen, dont push more left (so that the camera wont go off-map)

Then again, that might be inefficient, can't say since as I previously mentioned - I'm new to LOVE.

Re: top down camera

Posted: Wed Sep 05, 2012 8:00 pm
by Nixola
Not every pc supports Canvases - my netbook, for example, doesn't (on Windows; on Linux they work fine)

Re: top down camera

Posted: Wed Sep 05, 2012 8:02 pm
by qaisjp
Nixola wrote:Not every pc supports Canvases - my netbook, for example, doesn't (on Windows; on Linux they work fine)
True, even the (temporary, rubbish) pc I use now doesn't support it.

Re: top down camera

Posted: Wed Sep 05, 2012 8:12 pm
by qaisjp
Sorry for double post (:/)

I just looked at forked hump ( https://github.com/markandgo/hump ) and its the best for what you want, makes it much easier to support split screen for multiplayer etc. I recommend you to use this.

You might find the readme.md file examples hard to follow, but just check out the examples.

Re: top down camera

Posted: Wed Sep 05, 2012 8:13 pm
by bartbes
qaisjp wrote:Sorry for double post (:/)
You know there's an edit button, right?

Re: top down camera

Posted: Wed Sep 05, 2012 8:14 pm
by qaisjp
bartbes wrote:
qaisjp wrote:Sorry for double post (:/)
You know there's an edit button, right?
I am aware, but by double posting I notify people who already read my post that I updated it.

Re: top down camera

Posted: Wed Sep 05, 2012 8:35 pm
by Robin
In ten minutes time?

Re: top down camera

Posted: Wed Sep 05, 2012 8:42 pm
by Nixola
I read it