From cdc0f35f22d30c575094f93a1ff2bd85cbb13988 Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Sun, 21 Jul 2024 19:48:02 +0100 Subject: [PATCH] handling win states and moving stuff to be global --- main.lua | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/main.lua b/main.lua index 63705fd..3db4979 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,14 @@ 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:addCollisionClass("Player1") +World:addCollisionClass("Bullet1") +World:addCollisionClass("Player2") +World:addCollisionClass("Bullet2") +World:addCollisionClass("Wall") function love.run() if love.load then @@ -56,40 +66,25 @@ end function love.load() Object = require("libs/classic") + require("libs/restart") require("player") require("bullet") - - WF = require("libs/windfield") - STI = require("libs/sti") + 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("mapsloader") - - --WindField - World = WF.newWorld(0, 0) --no gravity - 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") - World:addCollisionClass("New") -- Used to make sure the bullet doesn't collide with the player that shot it - - --STI Map - loadMap(1) + require("Win/WinKeyPressed") --Fonts used in the game GameFont = love.graphics.newFont("assets/Daydream.ttf", 60) @@ -105,6 +100,8 @@ function love.load() Bullets1 = {} Bullets2 = {} + Walls = {} + DebugFlag = false EnableKeyPress1 = true KeyPressTime1 = 0 @@ -129,6 +126,9 @@ function love.load() volume = 0.7, highgain = 0.4, }) + + --STI Map loading + LoadMap(1) end function love.keypressed(key) @@ -141,6 +141,9 @@ function love.keypressed(key) if _G.GAMESTATE == "GAME" then GameKeyPressed(key) end + if _G.GAMESTATE == "WIN" then + WinKeyPressed(key) + end end function love.update(dt) @@ -173,9 +176,7 @@ function love.update(dt) end end if _G.GAMESTATE == "WIN" then - print(P1_WIN) - print(P2_WIN) - love.event.quit() + UpdateWin(dt) end end @@ -194,4 +195,7 @@ function love.draw() love.graphics.print("" .. GAMESTATE, 200, 200) end end + if _G.GAMESTATE == "WIN" then + DrawWin() + end end