added key delay
This commit is contained in:
parent
1731dbed8d
commit
e75d705e9b
@ -1,13 +1,24 @@
|
||||
function keyPressed(key)
|
||||
if EnableKeyPress == false then
|
||||
return --return early
|
||||
end
|
||||
|
||||
local bulletImg = "/assets/bullet.png"
|
||||
if key == "space" then
|
||||
local bullet = Bullet(UserPlayer1.x + UserPlayer1.width / 2, UserPlayer1.y, 1, "bullet.png", 500)
|
||||
local bullet = Bullet(UserPlayer1.x + UserPlayer1.width / 2, UserPlayer1.y, 1, bulletImg, 500)
|
||||
GameSounds.shoot1:play()
|
||||
table.insert(Bullets1, bullet)
|
||||
elseif key == "return" then
|
||||
local bullet = Bullet(UserPlayer2.x + UserPlayer2.width / 2, UserPlayer2.y, 2, "bullet.png", 500)
|
||||
local bullet = Bullet(UserPlayer2.x + UserPlayer2.width / 2, UserPlayer2.y, 2, bulletImg, 500)
|
||||
GameSounds.shoot2:play()
|
||||
table.insert(Bullets2, bullet)
|
||||
elseif key == "escape" then
|
||||
love.event.quit()
|
||||
elseif key == "r" then
|
||||
love.load()
|
||||
end
|
||||
|
||||
-- KeyPressTime now equals a delay
|
||||
KeyPressTime = KeyDelay
|
||||
EnableKeyPress = false
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user