2PlayerShooter/main.lua
2024-04-21 13:51:07 +01:00

71 lines
1.5 KiB
Lua

function love.load()
-- Objects, classes
Object = require("classic")
require("player")
require("bullet")
require("walls")
-- Lua files for the game
require("updateGame")
require("drawGame")
require("keyPressed")
love.math.setRandomSeed(os.time())
GameFont = love.graphics.newFont("Daydream.ttf", 60)
DebugFont = love.graphics.newFont("Daydream.ttf", 12)
love.graphics.setFont(GameFont)
ScrnHeight = love.graphics.getHeight()
ScrnWidth = love.graphics.getWidth()
EnableKeyPress1 = true
KeyPressTime1 = 0
KeyDelay1 = 0.5
EnableKeyPress2 = true
KeyPressTime2 = 0
KeyDelay2 = 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()
Player1Img = "/assets/player1.png"
Player2Img = "/assets/player2.png"
BulletImg = "/assets/bullet.png"
UserPlayer1 = Player(400, ScrnHeight - 30, 1, 3, Player1Img, 300)
UserPlayer2 = Player(200, 0, 2, 3, Player2Img, 300)
Bullets1 = {}
Bullets2 = {}
Walls = {}
TIMER = 10
TimeToPlaceWall = TIMER
HasP1Won = false
HasP2Won = false
end
function love.keypressed(key)
keyPressed(key)
end
function love.update(dt)
updateGame(dt)
end
function love.draw()
drawGame()
end