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

Showcase your libraries, tools and other projects that help your fellow love users.
XOdysseusX
Prole
Posts: 11
Joined: Fri Apr 26, 2013 3:32 pm

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

Post 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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

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

Post 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.
When I write def I mean function.
XOdysseusX
Prole
Posts: 11
Joined: Fri Apr 26, 2013 3:32 pm

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

Post by XOdysseusX »

:awesome: It works!

I gotta say Kikito, I'm pretty jealous of your talent.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

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

Post 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.
When I write def I mean function.
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

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

Post by rmcode »

How would I use gamera in a world which doesn't have "boundaries"?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

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

Post 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())
When I write def I mean function.
User avatar
konacake
Prole
Posts: 11
Joined: Mon Mar 03, 2014 4:35 am

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

Post 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!
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

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

Post by davisdude »

Before everything in love.load try:

Code: Select all

love.graphics.setDefaultFilter( 'nearest', 'nearest' )
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
konacake
Prole
Posts: 11
Joined: Mon Mar 03, 2014 4:35 am

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

Post 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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

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

Post 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.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests