Particles: Relative positioning?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
mrzapp
Prole
Posts: 8
Joined: Thu Jul 12, 2012 1:37 am

Particles: Relative positioning?

Post 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.
User avatar
mrzapp
Prole
Posts: 8
Joined: Thu Jul 12, 2012 1:37 am

Re: Particles: Relative positioning?

Post 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.
User avatar
furi
Citizen
Posts: 73
Joined: Sat Feb 26, 2011 8:15 pm

Re: Particles: Relative positioning?

Post by furi »

Try it without camera.x and camera.y. It depends on the way you're drawing, but this could possibly fix it.
User avatar
mrzapp
Prole
Posts: 8
Joined: Thu Jul 12, 2012 1:37 am

Re: Particles: Relative positioning?

Post 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?
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: Particles: Relative positioning?

Post 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
User avatar
mrzapp
Prole
Posts: 8
Joined: Thu Jul 12, 2012 1:37 am

Re: Particles: Relative positioning?

Post by mrzapp »

oh. wow, that is so much easier :D
thanks a lot, mate
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Particles: Relative positioning?

Post 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!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests