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.
[library] gamera - A camera system for LÖVE - v1.0.1 is out
-
- Prole
- Posts: 11
- Joined: Fri Apr 26, 2013 3:32 pm
- 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
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.
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.
-
- Prole
- Posts: 11
- Joined: Fri Apr 26, 2013 3:32 pm
Re: [library] gamera - A camera system for LÖVE - v1.0 is ou
It works!
I gotta say Kikito, I'm pretty jealous of your talent.
I gotta say Kikito, I'm pretty jealous of your talent.
- 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
glad it's working now. Thank you for helping me find a bug in my library, you have made it better for everyone else!XOdysseusX wrote: It works!
I gotta say Kikito, I'm pretty jealous of your talent.
I'm hereby releasing v1.0.1 of this lib officially.
When I write def I mean function.
Re: [library] gamera - A camera system for LÖVE - v1.0.1 is
How would I use gamera in a world which doesn't have "boundaries"?
- 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
Well, there are two options. One is using an arbitrarily large 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
local MAX_WORD_SIZE = 1000000
...
local camera = gamera.new(-MAX_WORLD_SIZE/2, -MAX_WORLD_SIZE/2, MAX_WORLD_SIZE, MAX_WORLD_SIZE)
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.
Re: [library] gamera - A camera system for LÖVE - v1.0.1 is
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
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
Re: [library] gamera - A camera system for LÖVE - v1.0.1 is
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.
- 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
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.
Who is online
Users browsing this forum: No registered users and 1 guest