Event Cool downs
Posted: Tue Aug 25, 2020 7:47 pm
I've been trying to make a game in which a character shoots a projectile. A problem I have is that bullets can be spammed can be shot right after one another so I wanted to make it so between each shot there is a 2 second cool down. I've attempted at creating a cool down and have succeeded but not in the way I want to. After pressing space the bolt shoots and starts the cool down. Sadly, after the cool down ends it immediately fires again without waiting for space to be pressed again when I want to to wait for space to be pressed again.
Here's my code:
function love.load()
cooldown = 0
end
function love.update(dt)
cooldown = math.max(cooldown - dt,0)
if love.wasReleased('space') and cooldown == 0 then
player1Bolt:reset()
cooldown = 2
player1Bolt.dx = BOLT_SPEED
end
end
Here's my code:
function love.load()
cooldown = 0
end
function love.update(dt)
cooldown = math.max(cooldown - dt,0)
if love.wasReleased('space') and cooldown == 0 then
player1Bolt:reset()
cooldown = 2
player1Bolt.dx = BOLT_SPEED
end
end