CAMERA: scrolling and scaling

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: CAMERA: scrolling and scaling

Post by whitebear »

Bug: Added the camera script to Ninja Ball but the image in the render looks like someone had ran over it with a truck.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: CAMERA: scrolling and scaling

Post by osuf oboys »

whitebear wrote:Bug: Added the camera script to Ninja Ball but the image in the render looks like someone had ran over it with a truck.
Provide more information if you want to report anything. What is wrong? I included camera.lua and everything looks like ordinary. I added a stretched resolution and it looks like it usually does (e.g. somewhat pixely if zoomed in a lot, some extra pixels if zoomed out a lot). Were you using a resolution with a different aspect ratio than the game window?
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
TheMyst
Prole
Posts: 6
Joined: Sat Mar 21, 2009 2:36 am

Re: CAMERA: scrolling and scaling

Post by TheMyst »

Now what I want to know is why has this not been part of Love already? This kind of thing is almost TOO useful to not include.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: CAMERA: scrolling and scaling

Post by Robin »

TheMyst wrote:Now what I want to know is why has this not been part of Love already? This kind of thing is almost TOO useful to not include.
I think this quote might answer your questions:
mike wrote:In the original idea we were going to be making an all-encompassing system with it's own GUI for browsing games, GUI system, A* navigation algorithm, map creation kit, kittens and giggles, etc, but that soon became unfeasable because the backbones of the system weren't implemented yet (image handling, sound, text, etc). As we worked on it the focus shifted from providing everything but the kitchen sink to more of making a good system for letting people provide their own features. We were going to have a built-in GUI system (see another thread somewhere on this forum), but people started making their own libraries so it quickly became apparent that building a good TOOL for people to base their work around was better than making it all ourselves (takes less time too).
Help us help you: attach a .love.
Zetty
Prole
Posts: 5
Joined: Wed Mar 25, 2009 6:50 pm

Re: CAMERA: scrolling and scaling

Post by Zetty »

Hi all,

I am trying out CAMERA, and I was wondering if someone could provide an/another example of redrawing a GUI in the same place while the rest of the screen moves? If I'm not mistaken, it needs two cameras?

Right now I'm using the "Screen following a body" but I believe I need another camera so it can redraw the GUI correctly? I'm having some trouble wrapping my head around the whole camera thing as it is. :|
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Re: CAMERA: scrolling and scaling

Post by Matkins »

I need to create a psuedo 3D effect where basically a background layer moves slower than the foreground layer. Can i do this with CAMERA? Thanks.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: CAMERA: scrolling and scaling

Post by osuf oboys »

Zetty wrote:Hi all,

I am trying out CAMERA, and I was wondering if someone could provide an/another example of redrawing a GUI in the same place while the rest of the screen moves? If I'm not mistaken, it needs two cameras?

Right now I'm using the "Screen following a body" but I believe I need another camera so it can redraw the GUI correctly? I'm having some trouble wrapping my head around the whole camera thing as it is. :|
See them as cameras you place in the world. They all look at different things but everything is drawn (in order) to the same screen. You can have one camera over there where the bad guys are fighting and one camera over there at the plaster scoreboard. When you draw something, it is only captured by the camera you are currently looking at. So you first want to look through the bad guy camera, draw the bad guys, switch and look through the scoreboard camera, and draw the scoreboard. As such, it won't be a problem if the two camera are even next to each other, the bad guys only exist while they're being drawn. So: create two cameras that look at a large enough scene each (e.g. small guys, large scoreboard - make the first camera look at something small and the second something large), set the bad guy camera as active, draw bad guys, set the scoreboard camera to active, draw the scoreboard.

See the example at http://love2d.org/wiki/index.php?title=CAMERA:Examples.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: CAMERA: scrolling and scaling

Post by osuf oboys »

Matkins wrote:I need to create a psuedo 3D effect where basically a background layer moves slower than the foreground layer. Can i do this with CAMERA? Thanks.
Certainly, take a look at the "ball for a stroll" demo at the start of this thread, the clouds are moving when you move but slower than the foreground.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
Tabasco
Citizen
Posts: 72
Joined: Tue Dec 02, 2008 5:04 pm

Re: CAMERA: scrolling and scaling

Post by Tabasco »

I kept meaning to check this out but I haven't had a lot of time. I just hooked it into MD in about five minutes with a few minor adjustments.
This has great utility, thanks for providing it.

Right now I'm performing the nasty love.system.restart() when resolution changes because just resetting the camera after calling love.graphics.setMode() doesn't seem to work. If there's a workaround that I'm missing, please let me know.

Again, thanks for this library, it's extremely useful.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: CAMERA: scrolling and scaling

Post by osuf oboys »

Tabasco wrote:I kept meaning to check this out but I haven't had a lot of time. I just hooked it into MD in about five minutes with a few minor adjustments.
This has great utility, thanks for providing it.

Right now I'm performing the nasty love.system.restart() when resolution changes because just resetting the camera after calling love.graphics.setMode() doesn't seem to work. If there's a workaround that I'm missing, please let me know.

Again, thanks for this library, it's extremely useful.
Ah, I'm sorry, I see why you had difficulties getting it to work as you wanted it to. For mouse callbacks, I change the camera to the "mouse camera" and back again after the callback. The camera you were changing to in the callback was therefore discarded and the game used the old resolution to draw. I'll upload a new version when I get back tomorrow. Do note that you do not need to reinitialize the GUI when changing cameras and that maincam is not needed.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests