|
|
|
@ -1,14 +1,4 @@ |
|
|
|
|
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 |
|
|
|
@ -66,25 +56,40 @@ end |
|
|
|
|
|
|
|
|
|
function love.load() |
|
|
|
|
Object = require("libs/classic") |
|
|
|
|
require("libs/restart") |
|
|
|
|
require("player") |
|
|
|
|
require("bullet") |
|
|
|
|
require("mapsloader") |
|
|
|
|
|
|
|
|
|
WF = require("libs/windfield") |
|
|
|
|
STI = require("libs/sti") |
|
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
--Fonts used in the game |
|
|
|
|
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60) |
|
|
|
@ -94,13 +99,12 @@ function love.load() |
|
|
|
|
--Game consts |
|
|
|
|
HEALTH = 3 |
|
|
|
|
DELAY = 0.5 |
|
|
|
|
MAX = 6 --MAX number of bullets| |
|
|
|
|
|
|
|
|
|
--Bullet lists |
|
|
|
|
Bullets1 = {} |
|
|
|
|
Bullets2 = {} |
|
|
|
|
|
|
|
|
|
Walls = {} |
|
|
|
|
|
|
|
|
|
DebugFlag = false |
|
|
|
|
EnableKeyPress1 = true |
|
|
|
|
KeyPressTime1 = 0 |
|
|
|
@ -115,9 +119,9 @@ function love.load() |
|
|
|
|
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 |
|
|
|
|
musicMenu = love.audio.newSource("music/menu.mp3", "stream") |
|
|
|
|
musicBattle = love.audio.newSource("music/battle.mp3", "stream") |
|
|
|
|
musicStory = love.audio.newSource("music/story.mp3", "stream") |
|
|
|
|
|
|
|
|
|
musicPause = musicBattle:clone() |
|
|
|
|
musicPause:setFilter({ |
|
|
|
@ -125,9 +129,6 @@ function love.load() |
|
|
|
|
volume = 0.7, |
|
|
|
|
highgain = 0.4, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
--STI Map loading |
|
|
|
|
LoadMap(1) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function love.keypressed(key) |
|
|
|
@ -140,9 +141,6 @@ 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) |
|
|
|
@ -175,7 +173,9 @@ function love.update(dt) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if _G.GAMESTATE == "WIN" then |
|
|
|
|
UpdateWin(dt) |
|
|
|
|
print(P1_WIN) |
|
|
|
|
print(P2_WIN) |
|
|
|
|
love.event.quit() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -194,7 +194,4 @@ function love.draw() |
|
|
|
|
love.graphics.print("" .. GAMESTATE, 200, 200) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if _G.GAMESTATE == "WIN" then |
|
|
|
|
DrawWin() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|