Camera logic to keep level and players within view

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
zell2002
Citizen
Posts: 75
Joined: Sun Feb 23, 2014 9:22 pm

Camera logic to keep level and players within view

Post by zell2002 »

I'm doing a platformer/beat em up like Smash Brothers, so I want the camera to stay on the characters while they move around.
I want the camera to follow the players and zoom out but have a limit relative to the level. I was thinking in my level editor id add a bounding box that says camera cant move further than these points and then maybe the same for a zoom out point.
I dont know if this the best approach.

Currently my camera code finds the middle point between all players and "Looks at" that point. When the distance between players reaches X the camera starts to pan out. The camera zooms in/out relative to the distance between players, but will eventually reach a max zoom and lock there.

I was wondering if anyone has any pointers/advice on this?
palmettos
Prole
Posts: 14
Joined: Sun May 29, 2016 7:00 pm

Re: Camera logic to keep level and players within view

Post by palmettos »

I'm personally using Tiled with bump and outlining my maps wherever I don't want the camera to go beyond with a special tile that has an attribute "camera_collide." I put the camera rect in the bump collision world and only process its collisions against tiles with the "camera_collide" attribute. It works pretty well so far.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: Camera logic to keep level and players within view

Post by alloyed »

For cameras I strongly suggest skimming this article:

http://www.gamasutra.com/blogs/ItayKere ... ollers.php

It's pretty exhaustive, including even the smash bros. example.
Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot], zorg and 3 guests