From 2e6fdcd3f0e2e725fbe0e5c7ebab7bffd2a9e8c8 Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Sun, 21 Apr 2024 13:38:08 +0100 Subject: [PATCH] added sounds and key delay --- main.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index 43dd82c..ec93e1b 100644 --- a/main.lua +++ b/main.lua @@ -19,8 +19,26 @@ function love.load() ScrnHeight = love.graphics.getHeight() ScrnWidth = love.graphics.getWidth() - UserPlayer1 = Player(400, ScrnHeight - 30, 1, 3, "player1.png", 300) - UserPlayer2 = Player(200, 0, 2, 3, "player2.png", 300) + EnableKeyPress = true + KeyPressTime = 0 + KeyDelay = 0.5 + + GameSounds = {} + --static, loaded into memory all time + --stream, loaded into memory when played + GameSounds.shoot1 = love.audio.newSource("/sounds/shoot1.wav", "static") + GameSounds.shoot2 = love.audio.newSource("/sounds/shoot2.wav", "static") + GameSounds.hit = love.audio.newSource("/sounds/hit.wav", "static") + GameSounds.bg = love.audio.newSource("/sounds/bgmusic.wav", "stream") + + GameSounds.bg:setLooping(true) + GameSounds.bg:setVolume(0.5) + GameSounds.bg:play() + + local player1Img = "/assets/player1.png" + local player2Img = "/assets/player2.png" + UserPlayer1 = Player(400, ScrnHeight - 30, 1, 3, player1Img, 300) + UserPlayer2 = Player(200, 0, 2, 3, player2Img, 300) Bullets1 = {} Bullets2 = {}