How to change gamestates pressing R and particle cleanup
Posted: Wed Sep 30, 2015 11:37 pm
SORRY IN ADVANCED FOR NOT USING .LOVE, FOR SOME REASON IT DOESN'T WORK USING .LOVE
ALSO SORRY FOR HAVING SUCH MESSY CODE.
I've been trying to make a space invader like game for practice, but for some reason, when I enter the gameover gamestate, I cant change back to the playing gamestate when i press R.
My gamestate system is just a string, so if you die for example your gamestate turns into "gameover" or if you're playing the gamestate is by default "playing". Now the thing is I've added a code where if you're in the game over state, you will go back to the playing gamestate via pressing R. This for some reason doesnt work.
Code goes like this
It doesn't give out an error or anything, it just doesn't work.
Also my second problem is the fact that my particles dont disappear even after adding in a system that removes the particle table when it reaches a certain tick point.
I've added this function to whenever an enemy dies, so this means that every enemy are sharing the same limit, meaning if I kill one enemy the particle limit will start counting down to 0 and when it does it will remove the particles AND restart the particle limit, but then this means that everytime I kill an enemy every particle will stay because they all share one time limit. Is there anyway to fix this?
ALSO SORRY FOR HAVING SUCH MESSY CODE.
I've been trying to make a space invader like game for practice, but for some reason, when I enter the gameover gamestate, I cant change back to the playing gamestate when i press R.
My gamestate system is just a string, so if you die for example your gamestate turns into "gameover" or if you're playing the gamestate is by default "playing". Now the thing is I've added a code where if you're in the game over state, you will go back to the playing gamestate via pressing R. This for some reason doesnt work.
Code goes like this
Code: Select all
elseif gamestate == "gameover" then
if love.keyboard.isDown("r") then
gamestate = "playing"
end
Also my second problem is the fact that my particles dont disappear even after adding in a system that removes the particle table when it reaches a certain tick point.
Code: Select all
function particle_systems:cleanup()
if particlelimit <= 0 then
table.remove(particle_systems.list)
particlelimit = 220
end
end