|
|
@ -12,7 +12,10 @@ World:addCollisionClass("Player2") |
|
|
|
World:addCollisionClass("Bullet2") |
|
|
|
World:addCollisionClass("Bullet2") |
|
|
|
World:addCollisionClass("Wall") |
|
|
|
World:addCollisionClass("Wall") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require("gui") |
|
|
|
|
|
|
|
|
|
|
|
require("restart") |
|
|
|
require("restart") |
|
|
|
|
|
|
|
require("truncate") |
|
|
|
require("player") |
|
|
|
require("player") |
|
|
|
require("bullet") |
|
|
|
require("bullet") |
|
|
|
require("mapsloader") |
|
|
|
require("mapsloader") |
|
|
@ -104,10 +107,25 @@ function love.run() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function love.load(args) |
|
|
|
function love.resized() |
|
|
|
|
|
|
|
--TOD0: fix scaling! |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function love.load() |
|
|
|
-- Set a random seed |
|
|
|
-- Set a random seed |
|
|
|
love.math.setRandomSeed(love.timer.getTime()) |
|
|
|
love.math.setRandomSeed(love.timer.getTime()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Figure out the X_SCALE and Y_SCALE |
|
|
|
|
|
|
|
local curWidth, curHeight = love.graphics.getDimensions() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("------") |
|
|
|
|
|
|
|
print(love.graphics.getDimensions()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_G.X_SCALE = truncate(curWidth / GAME_WORLD_DIM_WIDTH, 3) |
|
|
|
|
|
|
|
_G.Y_SCALE = truncate(curHeight / GAME_WORLD_DIM_HEIGHT, 3) |
|
|
|
|
|
|
|
print("x scale:" .. _G.X_SCALE) |
|
|
|
|
|
|
|
print("y scale:" .. _G.Y_SCALE) |
|
|
|
|
|
|
|
|
|
|
|
--Game values (reset after each load) |
|
|
|
--Game values (reset after each load) |
|
|
|
HEALTH = 3 |
|
|
|
HEALTH = 3 |
|
|
|
P1_DELAY = 0.5 |
|
|
|
P1_DELAY = 0.5 |
|
|
@ -127,6 +145,7 @@ function love.load(args) |
|
|
|
KeyDelay2 = P2_DELAY |
|
|
|
KeyDelay2 = P2_DELAY |
|
|
|
|
|
|
|
|
|
|
|
local playerSpeed = 12000 |
|
|
|
local playerSpeed = 12000 |
|
|
|
|
|
|
|
--TODO: two player speeds for upgrades |
|
|
|
UserPlayer1 = Player(1, 1000, 100, HEALTH, "assets/player1.png", playerSpeed) |
|
|
|
UserPlayer1 = Player(1, 1000, 100, HEALTH, "assets/player1.png", playerSpeed) |
|
|
|
UserPlayer2 = Player(2, 200, 300, HEALTH, "assets/player2.png", playerSpeed) |
|
|
|
UserPlayer2 = Player(2, 200, 300, HEALTH, "assets/player2.png", playerSpeed) |
|
|
|
|
|
|
|
|
|
|
@ -153,7 +172,7 @@ function love.update(dt) |
|
|
|
if _G.GAMESTATE == "MENU" then |
|
|
|
if _G.GAMESTATE == "MENU" then |
|
|
|
UpdateMenu(dt) |
|
|
|
UpdateMenu(dt) |
|
|
|
-- Handle music |
|
|
|
-- Handle music |
|
|
|
if not musicMenu:isPlaying() then |
|
|
|
if not musicMenu:isPlaying() and not _G.MUTED then |
|
|
|
musicMenu:setVolume(0.5) |
|
|
|
musicMenu:setVolume(0.5) |
|
|
|
love.audio.play(musicMenu) |
|
|
|
love.audio.play(musicMenu) |
|
|
|
end |
|
|
|
end |
|
|
@ -161,7 +180,7 @@ function love.update(dt) |
|
|
|
if _G.GAMESTATE == "PAUSE" then |
|
|
|
if _G.GAMESTATE == "PAUSE" then |
|
|
|
UpdatePause(dt) |
|
|
|
UpdatePause(dt) |
|
|
|
-- Handle music |
|
|
|
-- Handle music |
|
|
|
if not musicPause:isPlaying() then |
|
|
|
if not musicPause:isPlaying() and not _G.MUTED then |
|
|
|
musicBattle:setVolume(0) |
|
|
|
musicBattle:setVolume(0) |
|
|
|
musicPause:setVolume(0.5) |
|
|
|
musicPause:setVolume(0.5) |
|
|
|
love.audio.play(musicBattle) |
|
|
|
love.audio.play(musicBattle) |
|
|
@ -171,7 +190,7 @@ function love.update(dt) |
|
|
|
if _G.GAMESTATE == "GAME" then |
|
|
|
if _G.GAMESTATE == "GAME" then |
|
|
|
UpdateGame(dt) |
|
|
|
UpdateGame(dt) |
|
|
|
-- Handle music |
|
|
|
-- Handle music |
|
|
|
if not musicBattle:isPlaying() then |
|
|
|
if not musicBattle:isPlaying() and not _G.MUTED then |
|
|
|
musicBattle:setVolume(0.5) |
|
|
|
musicBattle:setVolume(0.5) |
|
|
|
musicPause:setVolume(0) |
|
|
|
musicPause:setVolume(0) |
|
|
|
love.audio.play(musicBattle) |
|
|
|
love.audio.play(musicBattle) |
|
|
@ -192,11 +211,6 @@ function love.draw() |
|
|
|
end |
|
|
|
end |
|
|
|
if _G.GAMESTATE == "GAME" then |
|
|
|
if _G.GAMESTATE == "GAME" then |
|
|
|
DrawGame() |
|
|
|
DrawGame() |
|
|
|
if DebugFlag then |
|
|
|
|
|
|
|
love.graphics.setFont(DebugFont) |
|
|
|
|
|
|
|
love.graphics.print("Debug Mode", 1200, 850) |
|
|
|
|
|
|
|
love.graphics.print("" .. GAMESTATE, 200, 200) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
if _G.GAMESTATE == "WIN" then |
|
|
|
if _G.GAMESTATE == "WIN" then |
|
|
|
DrawWin() |
|
|
|
DrawWin() |
|
|
|