Okay, you've got two problems - the particle system isn't showing up, and the ground is going away. Fortunately, both of those are very solvable!
You're almost there with the particle system. You get it to start when the player presses 'z'. But starting a ParticleSystem just gets it ready to go. In order for it to keep track of where all the particles are, it needs to be updated every frame, just like the rest of your game. What you need to do is,
inside love.update(dt), call ParticleSystem:update(dt). That way, every frame, your game will tell ParticleSystem to update itself, so that when it's drawn in love.draw(), the particles will be where they need to be.
However, even if you change this, the particles won't be drawn on screen if the player moves at all. Why? Because of your second problem. Take a look at your love.update - notice how you're redefining love.draw() when a key is down? That changes love.draw() from what it is originally to what you declare it as there. You're changing love.draw() dynamically, which is kinda cool, and a very useful trick. But in this case, it's overkill, and because the new love.draw()s only draw the shooter, and not the ground or the particle system, as soon as the player presses left or right, the game will only draw the shooter.
To fix that,
remove the love.draw() stuff from inside love.update. Instead, just set a variable that determines whether the player should face right or left. How you do that is up to you - you could use a string, a boolean, or some other identifier that has at least two different states. Then, just check for whether it's in the "left" state or the "right" state inside love.draw(), and draw the appropriate image.
One last thing: love.keyboard.isDown() checks every frame, which is overkill for just starting/stopping a ParticleSystem. I'd recommend taking that part out of love.update, and moving it into a love.keypressed() callback, like so:
Code: Select all
function love.keypressed(key)
if key == "z" then
ParticleSystem:setPosition(Px, Py)
ParticleSystem:start()
end
end
Hope this helps!
EDIT: One last last thing that I noticed in testing out your code. The particles still won't be drawn on screen, even if you follow all of the above. Because you're trying to draw it outside of the boundaries. When love.graphics.draw() draws a ParticleSystem at a certain point, it offsets it by the ParticleSystem's position - which you've set already, to (Px, Py), or (350, 350). So, when you set its position to (350, 350), and then tell love.graphics.draw to draw it at (350, 350), the end result is you're drawing it at (700, 700) - a location which is outside of the window.
I'll leave it as an exercise to you how you go about fixing this.