Page 1 of 1

Particles: Relative positioning?

Posted: Thu Jul 12, 2012 1:57 am
by mrzapp
Hi,

I am trying to integrate some particle effects into our game.

I am using a table called "camera" with variables "x" and "y" to scroll a level in relation to the player. So, for instance, when I draw the player, it's drawn to player.x + camera.x and player.y + camera.y.

However, when I want to position a particle system on the player, I set it to player.x+camera.x, player.y+camera.y, and it works, but the particles themselves are not being drawn relative to the camera, like the emission point is. That is, I assume, because the particle emitter doesn't care about the camera.x and camera.y variables.

Is there a way that I can make this happen?
Thanks in advance.

Re: Particles: Relative positioning?

Posted: Thu Jul 12, 2012 8:06 am
by mrzapp
Just to be extra clear, what I would like is to add the camera.x and the camera.y value to the x and y properties of every individual particle.

Re: Particles: Relative positioning?

Posted: Thu Jul 12, 2012 11:53 am
by furi
Try it without camera.x and camera.y. It depends on the way you're drawing, but this could possibly fix it.

Re: Particles: Relative positioning?

Posted: Fri Jul 13, 2012 2:18 am
by mrzapp
I might see your point there, but how do I scroll through a level without adding an x and y value to every object?

Re: Particles: Relative positioning?

Posted: Fri Jul 13, 2012 3:29 am
by dreadkillz
You can transform your entire coordinate systems without changing their "world" coordinates. So your object could just be at point (x,y) and you draw your particles at (x,y) without adding all that camera.x,camera.y stuff. This is useful for scrolling and for making a camera system. See love.graphics.translate, love.graphics.scale, etc. https://love2d.org/wiki/love.graphics.translate

Re: Particles: Relative positioning?

Posted: Wed Jul 18, 2012 2:46 am
by mrzapp
oh. wow, that is so much easier :D
thanks a lot, mate

Re: Particles: Relative positioning?

Posted: Wed Jul 18, 2012 5:15 pm
by Jasoco
Yeah, before I learned about love.graphics.translate() I used to add the level offset to each object. Translate made it so much easier and braindead simple. I felt silly. Live and learn!