top down 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.
russ_e
Prole
Posts: 11
Joined: Wed Sep 05, 2012 12:15 pm

top down camera

Post 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 :)
Attachments
topdown.love
(72.16 KiB) Downloaded 173 times
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: top down camera

Post 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...
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: top down camera

Post 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.
Lua is not an acronym.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: top down camera

Post by Nixola »

Not every pc supports Canvases - my netbook, for example, doesn't (on Windows; on Linux they work fine)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: top down camera

Post 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.
Lua is not an acronym.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: top down camera

Post 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.
Lua is not an acronym.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: top down camera

Post by bartbes »

qaisjp wrote:Sorry for double post (:/)
You know there's an edit button, right?
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: top down camera

Post 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.
Lua is not an acronym.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: top down camera

Post by Robin »

In ten minutes time?
Help us help you: attach a .love.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: top down camera

Post by Nixola »

I read it
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests