Page 3 of 7

Re: [library] gamera - A camera system for LÖVE - v1.0 is ou

Posted: Sun Apr 28, 2013 2:21 pm
by XOdysseusX
I'm trying to get the player's body position relative to the screen. The answer here should be to use toScreen, but for some reason it still gives me the position in the world.

For now, I have centered the player onto the screen, so his relative position is half the width and half the height, but that's not always going to be the case, which is why I need toScreen to work.

When you hold down "s" and right click, it displays the value of x and y after toScreen is called, and it's obviously not 300, 400.

If you want to look at the code for it, it's in the player class.

Exactly why I'm trying to achieve: Using the gamera:toScreen(x,y) method to get the position of the player's body relative to the screen.

Re: [library] gamera - A camera system for LÖVE - v1.0 is ou

Posted: Sun Apr 28, 2013 3:58 pm
by kikito
Oh, my. You are right. toScreen was not working as it should. I assumed it worked fine because it was being used to calculate the corners of the visible corners, but it turns out that assumption itself was bad. I extend you my apologies.

I think I've fixed it now. Please try with the version I've just published on github and let me know if it solves your issue.

Re: [library] gamera - A camera system for LÖVE - v1.0 is ou

Posted: Sun Apr 28, 2013 6:53 pm
by XOdysseusX
:awesome: It works!

I gotta say Kikito, I'm pretty jealous of your talent.

Re: [library] gamera - A camera system for LÖVE - v1.0 is ou

Posted: Sun Apr 28, 2013 11:31 pm
by kikito
XOdysseusX wrote::awesome: It works!

I gotta say Kikito, I'm pretty jealous of your talent.
:3 glad it's working now. Thank you for helping me find a bug in my library, you have made it better for everyone else!

I'm hereby releasing v1.0.1 of this lib officially.

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Thu Mar 19, 2015 2:30 pm
by rmcode
How would I use gamera in a world which doesn't have "boundaries"?

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Thu Mar 19, 2015 4:06 pm
by kikito
Well, there are two options. One is using an arbitrarily large size:

Code: Select all

local MAX_WORD_SIZE = 1000000

...
local camera = gamera.new(-MAX_WORLD_SIZE/2, -MAX_WORLD_SIZE/2, MAX_WORLD_SIZE, MAX_WORLD_SIZE)
Make MAX_WORLD_SIZE as big as you need (I would recommend *not* making it math.huge, because those sizes are still used in some calculations, and math.huge can throw up wrong values with them).

The other option is reseting the world size as time passes. Even if your game world is theoretically infinite, the computer's memory available to model it is not. You will have to "load up" new parts of the world and "discard" old ones as the player moves.

Every time you "free up memory and load up new parts of the world", change the camera's world size with setWorld, so that it covers the "currently loaded part":

Code: Select all

  myWorld:cleanupAndLoadAround(player.x, player.y)
  camera:setWorld(myWorld:getLoadedBoundary())

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Mon Apr 27, 2015 11:20 pm
by konacake
Hi, I notice when I zoom in using setScale, everything's a little blurry. Is there any way to fix this? Maybe a few lines in the library I should alter? I didn't see an option in the readme for it and my knowledge for how Love cameras work is pretty minimal. Thanks! It's wonderful library by the way, I fell in love with it instantly. So simple!

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Tue Apr 28, 2015 1:20 am
by davisdude
Before everything in love.load try:

Code: Select all

love.graphics.setDefaultFilter( 'nearest', 'nearest' )

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Tue Apr 28, 2015 1:28 am
by konacake
wow, thanks davisdude! Sorry kikito, I thought it was your library doing that, I really don't know much about camera systems. If I could make a suggestion, maybe put a note about that in the readme on the github.

Re: [library] gamera - A camera system for LÖVE - v1.0.1 is

Posted: Tue Apr 28, 2015 8:41 am
by kikito
I have added a FAQ section to the README with a couple problems people usually have with LÖVE (including the filter one), and how to fix them.