From df4184eec4a0c0ea540cd3823443401060c84d6c Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Wed, 24 Jul 2024 15:58:44 +0100 Subject: [PATCH] moved stuff out of love.load --- main.lua | 80 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/main.lua b/main.lua index 75a4d51..9aad773 100644 --- a/main.lua +++ b/main.lua @@ -1,21 +1,55 @@ +Object = require("libs/classic") + require("constants") WF = require("libs/windfield") STI = require("libs/sti") World = WF.newWorld(0, 0) --no gravity -World:setQueryDebugDrawing(true) -- Draws the area of a query for 10 frames +--World:setQueryDebugDrawing(true) -- Draws the area of a query for 10 frames World:addCollisionClass("Player1") World:addCollisionClass("Bullet1") World:addCollisionClass("Player2") World:addCollisionClass("Bullet2") World:addCollisionClass("Wall") +require("restart") +require("player") +require("bullet") +require("mapsloader") + +require("Game/UpdateGame") +require("Menu/UpdateMenu") +require("Pause/UpdatePause") +require("Win/UpdateWin") + +require("Game/DrawGame") +require("Menu/DrawMenu") +require("Pause/DrawPause") +require("Win/DrawWin") + +require("Game/GameKeyPressed") +require("Menu/MenuKeyPressed") +require("Pause/PauseKeyPressed") +require("Win/WinKeyPressed") + --Fonts used in the game GameFont = love.graphics.newFont("assets/Daydream.ttf", 60) DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12) MenuFont = love.graphics.newFont("assets/Daydream.ttf", 45) Walls = {} +-- Music streaming +musicMenu = love.audio.newSource("music/menu.mp3", "stream") or nil +musicBattle = love.audio.newSource("music/battle.mp3", "stream") or nil +--musicStory = love.audio.newSource("music/story.mp3", "stream") or nil + +musicPause = musicBattle:clone() +musicPause:setFilter({ + type = "lowpass", + volume = 0.7, + highgain = 0.4, +}) + function love.run() if love.load then love.load(love.arg.parseGameArguments(arg), arg) @@ -70,34 +104,14 @@ function love.run() end end -function love.load() - Object = require("libs/classic") - require("libs/restart") - require("player") - require("bullet") - require("mapsloader") - - require("Game/UpdateGame") - require("Menu/UpdateMenu") - require("Pause/UpdatePause") - require("Win/UpdateWin") - - require("Game/DrawGame") - require("Menu/DrawMenu") - require("Pause/DrawPause") - require("Win/DrawWin") - - require("Game/GameKeyPressed") - require("Menu/MenuKeyPressed") - require("Pause/PauseKeyPressed") - require("Win/WinKeyPressed") - +function love.load(args) -- Set a random seed love.math.setRandomSeed(love.timer.getTime()) - --Game consts + --Game values (reset after each load) HEALTH = 3 - DELAY = 0.5 + P1_DELAY = 0.5 + P2_DELAY = 0.5 --Bullet lists Bullets1 = {} @@ -106,28 +120,16 @@ function love.load() DebugFlag = false EnableKeyPress1 = true KeyPressTime1 = 0 - KeyDelay1 = DELAY + KeyDelay1 = P1_DELAY EnableKeyPress2 = true KeyPressTime2 = 0 - KeyDelay2 = DELAY + KeyDelay2 = P2_DELAY local playerSpeed = 12000 UserPlayer1 = Player(1, 1000, 100, HEALTH, "assets/player1.png", playerSpeed) UserPlayer2 = Player(2, 200, 300, HEALTH, "assets/player2.png", playerSpeed) - -- Music streaming - musicMenu = love.audio.newSource("music/menu.mp3", "stream") or nil - musicBattle = love.audio.newSource("music/battle.mp3", "stream") or nil - --musicStory = love.audio.newSource("music/story.mp3", "stream") or nil - - musicPause = musicBattle:clone() - musicPause:setFilter({ - type = "lowpass", - volume = 0.7, - highgain = 0.4, - }) - --STI Map loading LoadMap(_G.CUR_LEVEL) end