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