handling win states and moving stuff to be global

main
Simon Kellet 4 months ago
parent e83ee4ec64
commit cdc0f35f22
  1. 50
      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

Loading…
Cancel
Save