Page 1 of 1

newb Q: particle demo help...

Posted: Mon Feb 01, 2010 2:03 am
by Xoria
To this, how can add a circle shape to this list of particle systems and make it appear when you click? Is that even possible? I really don't get how bodies work. Worlds are easy to get though, but still. Let me know if you need the full modded demo code.

Code: Select all

------1
   local p = love.graphics.newParticleSystem(part1, 1000)
   p:setEmissionRate(100)
   p:setSpeed(300, 400)
   p:setGravity(0)
   p:setSize(2, 1)
   p:setColor(255, 255, 255, 255, 58, 128, 255, 0)
   p:setPosition(400, 300)
   p:setLifetime(1)
   p:setParticleLife(1)
   p:setDirection(0)
   p:setSpread(360)
   p:setRadialAcceleration(-2000)
   p:setTangentialAcceleration(1000)
   p:stop()
   table.insert(systems, p)

-------2
   p = love.graphics.newParticleSystem(part1, 1000)
   p:setEmissionRate(200)
   p:setSpeed(0.001, 0.005)
   p:setSize(0.11, 0.13)
   p:setColor(255, 255, 255, 5, 255, 128, 128, 220)
   p:setPosition(400, 300)
   p:setLifetime(1)
   p:setParticleLife(2)
   p:setDirection(0)
   p:setSpread(360)
   p:setTangentialAcceleration(2000)
   p:setRadialAcceleration(-10)
   p:stop()
   table.insert(systems, p)    

Re: newb Q: particle demo help...

Posted: Mon Feb 01, 2010 1:27 pm
by Alex McKee
There is a set of variables at the top of the main loop. For example:

Code: Select all

square = love.graphics.newImage("square.png")
To add a new type just create a plain, solid filled circle in a good drawing software such as Illustrator or Inkscape and export a PNG at 32px, which is the size of the others, or whichever size you want.

Put that image in the directory with the other PNG files and add an extra variable to the set.

Code: Select all

circle = love.graphics.newImage("circle.png")
Then create your new set with that circle variable.

Code: Select all

local p = love.graphics.newParticleSystem(circle, 1000)
To change the particle effects see the Particle system functions.

Re: newb Q: particle demo help...

Posted: Mon Feb 01, 2010 4:07 pm
by Robin
Xoria wrote:I really don't get how bodies work. Worlds are easy to get though, but still.
Shapes, Bodies and Worlds have nothing to do with graphics, including particle systems. They are objects in the Box2D physics simulation.

Re: newb Q: particle demo help...

Posted: Mon Feb 01, 2010 10:56 pm
by Xoria
Appreciate the help.

Just wondering, can one enable particles to be effected by collision like bodies?

Re: newb Q: particle demo help...

Posted: Tue Feb 02, 2010 1:41 am
by Taehl
You could always just put particle graphics on weightless physics bodies, for small-scale effects...

Re: newb Q: particle demo help...

Posted: Tue Feb 02, 2010 5:37 pm
by Xoria
Right, but if I can't click to draw a body, then I might as well use particles in my case, right?

Re: newb Q: particle demo help...

Posted: Tue Feb 02, 2010 6:08 pm
by Robin
Xoria wrote:Right, but if I can't click to draw a body, then I might as well use particles in my case, right?
Well, bodies only have a position, velocity, mass, ect, but no graphical representation. I'm not sure why you are even considering anything else than particles for a particle demo. ;)

Re: newb Q: particle demo help...

Posted: Tue Feb 02, 2010 9:15 pm
by Xoria
Good point lol. I'm using the particle demo as a start point for me to make a space like game w/ planets. A game like this requires a lot of particle effects and those bodies. I planed to make the planets by creating bodies, but it's easier to draw the particle way. (I want my game to feature mainly drawing), so what should I do for the planets?

Re: newb Q: particle demo help...

Posted: Tue Feb 02, 2010 9:50 pm
by Robin
Well, Box2D is not fit for games set in space, so I'd say write your own collision checking.

It's what I do with my Space game: planets are just tables with x, y and a radius. Then, I iterate over all spaceships and calculate gravity and collisions.