Compare commits
No commits in common. "f689632a92a031f3952d819e3b937d2bbd05177d" and "9e968b93900b10c763224d4add61ec4c69645e77" have entirely different histories.
f689632a92
...
9e968b9390
@ -18,16 +18,4 @@ function GameKeyPressed(key)
|
|||||||
_G.GAMESTATE = "GAME"
|
_G.GAMESTATE = "GAME"
|
||||||
love.load()
|
love.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- debug map changes!
|
|
||||||
if DebugFlag and key == "1" then
|
|
||||||
_G.CUR_LEVEL = 1
|
|
||||||
RestartGame()
|
|
||||||
love.load()
|
|
||||||
end
|
|
||||||
if DebugFlag and key == "2" then
|
|
||||||
_G.CUR_LEVEL = 2
|
|
||||||
RestartGame()
|
|
||||||
love.load()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
local function checkLossState()
|
local function checkWinState()
|
||||||
-- Check P1's health
|
-- Check P1's health
|
||||||
if UserPlayer1.health <= 0 then --P1 Lost, P2 Win
|
if UserPlayer1.health <= 0 then --P1 win
|
||||||
_G.P2_COUNT = _G.P2_COUNT + 1
|
|
||||||
_G.P1_WIN = false
|
_G.P1_WIN = false
|
||||||
_G.P2_WIN = true
|
_G.P2_WIN = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if UserPlayer2.health <= 0 then --P2 Lost, P1 Win
|
if UserPlayer2.health <= 0 then --P2 win
|
||||||
_G.P1_COUNT = _G.P1_COUNT + 1
|
|
||||||
_G.P1_WIN = true
|
_G.P1_WIN = true
|
||||||
_G.P2_WIN = false
|
_G.P2_WIN = false
|
||||||
return true
|
return true
|
||||||
@ -20,7 +18,7 @@ local max = math.max -- optimisations
|
|||||||
|
|
||||||
function UpdateGame(dt)
|
function UpdateGame(dt)
|
||||||
--Check if anyone has won
|
--Check if anyone has won
|
||||||
if checkLossState() == true then
|
if checkWinState() == true then
|
||||||
print("STATE CHNAGED: WIN!")
|
print("STATE CHNAGED: WIN!")
|
||||||
_G.GAMESTATE = "WIN"
|
_G.GAMESTATE = "WIN"
|
||||||
end
|
end
|
||||||
|
@ -38,6 +38,7 @@ function MenuKeyPressed(key)
|
|||||||
musicBattle:stop()
|
musicBattle:stop()
|
||||||
musicMenu:stop()
|
musicMenu:stop()
|
||||||
musicPause:stop()
|
musicPause:stop()
|
||||||
|
musicStory:stop()
|
||||||
_G.GAMESTATE = "MENU"
|
_G.GAMESTATE = "MENU"
|
||||||
love.load()
|
love.load()
|
||||||
end
|
end
|
||||||
|
@ -4,9 +4,9 @@ local function winner()
|
|||||||
local opacity = 0.3
|
local opacity = 0.3
|
||||||
local s = ""
|
local s = ""
|
||||||
|
|
||||||
if not _G.P1_WIN then
|
if _G.P1_WIN then
|
||||||
s = "P1 Win! R - Restart"
|
s = "P1 Win! R - Restart"
|
||||||
elseif not _G.P2_WIN then
|
elseif _G.P2_WIN then
|
||||||
s = "P2 Win! R - Restart"
|
s = "P2 Win! R - Restart"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -23,12 +23,7 @@ local function winner()
|
|||||||
|
|
||||||
love.graphics.setFont(MenuFont)
|
love.graphics.setFont(MenuFont)
|
||||||
love.graphics.setColor(1, 1, 1) -- white
|
love.graphics.setColor(1, 1, 1) -- white
|
||||||
love.graphics.print(s, centreX - sw / 2, centreY - sh / 2) -- who won
|
love.graphics.print(s, centreX - sw / 2, centreY - sh / 2)
|
||||||
love.graphics.print(
|
|
||||||
"" .. _G.P1_COUNT .. ":" .. "" .. _G.P2_COUNT,
|
|
||||||
(centreX - sw / 2),
|
|
||||||
(centreY - sh / 2) - sh / 1.5
|
|
||||||
) -- score
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,6 +26,3 @@ P2_WIN = false
|
|||||||
-- WIN counts!
|
-- WIN counts!
|
||||||
P1_COUNT = 0
|
P1_COUNT = 0
|
||||||
P2_COUNT = 0
|
P2_COUNT = 0
|
||||||
|
|
||||||
-- Current Level
|
|
||||||
CUR_LEVEL = 1
|
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
-- all objects
|
-- all objects
|
||||||
-- Used in map switching and restarting!
|
-- Used in map switching and restarting!
|
||||||
|
|
||||||
function ClearWalls(walls)
|
function ClearWalls()
|
||||||
for i = #walls, 1, -1 do
|
for w in pairs(Walls) do
|
||||||
walls[i]:destroy()
|
Walls[w] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Walls = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function StopAllMusic()
|
function StopAllMusic()
|
||||||
@ -41,7 +43,7 @@ function RestartGame()
|
|||||||
ClearBullets(Bullets2)
|
ClearBullets(Bullets2)
|
||||||
|
|
||||||
--Clear Walls
|
--Clear Walls
|
||||||
ClearWalls(Walls)
|
--ClearWalls()
|
||||||
|
|
||||||
-- Done!
|
-- Done!
|
||||||
end
|
end
|
||||||
|
24
main.lua
24
main.lua
@ -10,12 +10,6 @@ World:addCollisionClass("Player2")
|
|||||||
World:addCollisionClass("Bullet2")
|
World:addCollisionClass("Bullet2")
|
||||||
World:addCollisionClass("Wall")
|
World:addCollisionClass("Wall")
|
||||||
|
|
||||||
--Fonts used in the game
|
|
||||||
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60)
|
|
||||||
DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12)
|
|
||||||
MenuFont = love.graphics.newFont("assets/Daydream.ttf", 45)
|
|
||||||
Walls = {}
|
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
if love.load then
|
if love.load then
|
||||||
love.load(love.arg.parseGameArguments(arg), arg)
|
love.load(love.arg.parseGameArguments(arg), arg)
|
||||||
@ -92,8 +86,10 @@ function love.load()
|
|||||||
require("Pause/PauseKeyPressed")
|
require("Pause/PauseKeyPressed")
|
||||||
require("Win/WinKeyPressed")
|
require("Win/WinKeyPressed")
|
||||||
|
|
||||||
-- Set a random seed
|
--Fonts used in the game
|
||||||
love.math.setRandomSeed(love.timer.getTime())
|
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60)
|
||||||
|
DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12)
|
||||||
|
MenuFont = love.graphics.newFont("assets/Daydream.ttf", 45)
|
||||||
|
|
||||||
--Game consts
|
--Game consts
|
||||||
HEALTH = 3
|
HEALTH = 3
|
||||||
@ -103,6 +99,8 @@ function love.load()
|
|||||||
Bullets1 = {}
|
Bullets1 = {}
|
||||||
Bullets2 = {}
|
Bullets2 = {}
|
||||||
|
|
||||||
|
Walls = {}
|
||||||
|
|
||||||
DebugFlag = false
|
DebugFlag = false
|
||||||
EnableKeyPress1 = true
|
EnableKeyPress1 = true
|
||||||
KeyPressTime1 = 0
|
KeyPressTime1 = 0
|
||||||
@ -129,7 +127,7 @@ function love.load()
|
|||||||
})
|
})
|
||||||
|
|
||||||
--STI Map loading
|
--STI Map loading
|
||||||
LoadMap(_G.CUR_LEVEL)
|
LoadMap(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
@ -160,8 +158,8 @@ function love.update(dt)
|
|||||||
UpdatePause(dt)
|
UpdatePause(dt)
|
||||||
-- Handle music
|
-- Handle music
|
||||||
if not musicPause:isPlaying() then
|
if not musicPause:isPlaying() then
|
||||||
musicBattle:setVolume(0)
|
--musicBattle:setVolume(0)
|
||||||
musicPause:setVolume(0.5)
|
--musicPause:setVolume(0.5)
|
||||||
love.audio.play(musicBattle)
|
love.audio.play(musicBattle)
|
||||||
love.audio.play(musicPause)
|
love.audio.play(musicPause)
|
||||||
end
|
end
|
||||||
@ -170,8 +168,8 @@ function love.update(dt)
|
|||||||
UpdateGame(dt)
|
UpdateGame(dt)
|
||||||
-- Handle music
|
-- Handle music
|
||||||
if not musicBattle:isPlaying() then
|
if not musicBattle:isPlaying() then
|
||||||
musicBattle:setVolume(0.5)
|
--musicBattle:setVolume(0.5)
|
||||||
musicPause:setVolume(0)
|
--musicPause:setVolume(0)
|
||||||
love.audio.play(musicBattle)
|
love.audio.play(musicBattle)
|
||||||
love.audio.play(musicPause)
|
love.audio.play(musicPause)
|
||||||
end
|
end
|
||||||
|
290
maps/map2.lua
290
maps/map2.lua
@ -1,290 +0,0 @@
|
|||||||
return {
|
|
||||||
version = "1.10",
|
|
||||||
luaversion = "5.1",
|
|
||||||
tiledversion = "1.11.0",
|
|
||||||
class = "",
|
|
||||||
orientation = "orthogonal",
|
|
||||||
renderorder = "right-down",
|
|
||||||
width = 25,
|
|
||||||
height = 15,
|
|
||||||
tilewidth = 64,
|
|
||||||
tileheight = 64,
|
|
||||||
nextlayerid = 4,
|
|
||||||
nextobjectid = 16,
|
|
||||||
properties = {},
|
|
||||||
tilesets = {
|
|
||||||
{
|
|
||||||
name = "floor",
|
|
||||||
firstgid = 1,
|
|
||||||
class = "",
|
|
||||||
tilewidth = 64,
|
|
||||||
tileheight = 64,
|
|
||||||
spacing = 0,
|
|
||||||
margin = 0,
|
|
||||||
columns = 9,
|
|
||||||
image = "../assets/tileset.png",
|
|
||||||
imagewidth = 576,
|
|
||||||
imageheight = 384,
|
|
||||||
objectalignment = "unspecified",
|
|
||||||
tilerendersize = "tile",
|
|
||||||
fillmode = "stretch",
|
|
||||||
tileoffset = {
|
|
||||||
x = 0,
|
|
||||||
y = 0
|
|
||||||
},
|
|
||||||
grid = {
|
|
||||||
orientation = "orthogonal",
|
|
||||||
width = 64,
|
|
||||||
height = 64
|
|
||||||
},
|
|
||||||
properties = {},
|
|
||||||
wangsets = {},
|
|
||||||
tilecount = 54,
|
|
||||||
tiles = {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
layers = {
|
|
||||||
{
|
|
||||||
type = "tilelayer",
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
width = 25,
|
|
||||||
height = 15,
|
|
||||||
id = 1,
|
|
||||||
name = "floor",
|
|
||||||
class = "",
|
|
||||||
visible = true,
|
|
||||||
opacity = 1,
|
|
||||||
offsetx = 0,
|
|
||||||
offsety = 0,
|
|
||||||
parallaxx = 1,
|
|
||||||
parallaxy = 1,
|
|
||||||
properties = {},
|
|
||||||
encoding = "lua",
|
|
||||||
data = {
|
|
||||||
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
|
|
||||||
19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type = "tilelayer",
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
width = 25,
|
|
||||||
height = 15,
|
|
||||||
id = 2,
|
|
||||||
name = "inner walls",
|
|
||||||
class = "",
|
|
||||||
visible = true,
|
|
||||||
opacity = 1,
|
|
||||||
offsetx = 0,
|
|
||||||
offsety = 0,
|
|
||||||
parallaxx = 1,
|
|
||||||
parallaxy = 1,
|
|
||||||
properties = {},
|
|
||||||
encoding = "lua",
|
|
||||||
data = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 28, 29, 29, 29, 29, 29, 30, 0, 0, 37, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 37, 38, 38, 38, 38, 38, 39, 0, 0, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 46, 47, 38, 38, 38, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 38, 38, 38, 29, 30, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 0, 0, 37, 38, 38, 38, 38, 38, 39, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 38, 39, 0, 0, 46, 47, 47, 47, 47, 47, 48, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type = "objectgroup",
|
|
||||||
draworder = "topdown",
|
|
||||||
id = 3,
|
|
||||||
name = "Walls",
|
|
||||||
class = "",
|
|
||||||
visible = false,
|
|
||||||
opacity = 1,
|
|
||||||
offsetx = 0,
|
|
||||||
offsety = 0,
|
|
||||||
parallaxx = 1,
|
|
||||||
parallaxy = 1,
|
|
||||||
properties = {},
|
|
||||||
objects = {
|
|
||||||
{
|
|
||||||
id = 1,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 128,
|
|
||||||
y = 128,
|
|
||||||
width = 448,
|
|
||||||
height = 192,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 2,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 256,
|
|
||||||
y = 320,
|
|
||||||
width = 192,
|
|
||||||
height = 320,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 3,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 704,
|
|
||||||
y = 80,
|
|
||||||
width = 192,
|
|
||||||
height = 176,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 4,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 704,
|
|
||||||
y = 320,
|
|
||||||
width = 192,
|
|
||||||
height = 320,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 5,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 704,
|
|
||||||
y = 704,
|
|
||||||
width = 192,
|
|
||||||
height = 192,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 6,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 1024,
|
|
||||||
y = 640,
|
|
||||||
width = 448,
|
|
||||||
height = 192,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 7,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 1152,
|
|
||||||
y = 320,
|
|
||||||
width = 192,
|
|
||||||
height = 320,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 9,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
width = 1184,
|
|
||||||
height = 16,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 10,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 1184,
|
|
||||||
y = 0,
|
|
||||||
width = 416,
|
|
||||||
height = 16,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 11,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 1584,
|
|
||||||
y = 0,
|
|
||||||
width = 16,
|
|
||||||
height = 960,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 12,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 0,
|
|
||||||
y = 944,
|
|
||||||
width = 1600,
|
|
||||||
height = 16,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 13,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
width = 16,
|
|
||||||
height = 960,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="25" height="15" tilewidth="64" tileheight="64" infinite="0" nextlayerid="4" nextobjectid="16">
|
|
||||||
<editorsettings>
|
|
||||||
<export target="map2.lua" format="lua"/>
|
|
||||||
</editorsettings>
|
|
||||||
<tileset firstgid="1" name="floor" tilewidth="64" tileheight="64" tilecount="54" columns="9">
|
|
||||||
<image source="../assets/tileset.png" width="576" height="384"/>
|
|
||||||
</tileset>
|
|
||||||
<layer id="1" name="floor" width="25" height="15">
|
|
||||||
<data encoding="csv">
|
|
||||||
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
|
|
||||||
19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21
|
|
||||||
</data>
|
|
||||||
</layer>
|
|
||||||
<layer id="2" name="inner walls" width="25" height="15">
|
|
||||||
<data encoding="csv">
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,28,29,30,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,28,29,29,29,29,29,30,0,0,37,38,39,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,37,38,38,38,38,38,39,0,0,46,47,48,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,46,47,38,38,38,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,37,38,39,0,0,0,0,28,29,30,0,0,0,0,28,29,30,0,0,0,0,
|
|
||||||
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
|
|
||||||
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
|
|
||||||
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
|
|
||||||
0,0,0,0,46,47,48,0,0,0,0,46,47,48,0,0,0,0,37,38,39,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,29,38,38,38,29,30,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,28,29,30,0,0,37,38,38,38,38,38,39,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,37,38,39,0,0,46,47,47,47,47,47,48,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,46,47,48,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
</data>
|
|
||||||
</layer>
|
|
||||||
<objectgroup id="3" name="Walls" visible="0">
|
|
||||||
<object id="1" x="128" y="128" width="448" height="192"/>
|
|
||||||
<object id="2" x="256" y="320" width="192" height="320"/>
|
|
||||||
<object id="3" x="704" y="80" width="192" height="176"/>
|
|
||||||
<object id="4" x="704" y="320" width="192" height="320"/>
|
|
||||||
<object id="5" x="704" y="704" width="192" height="192"/>
|
|
||||||
<object id="6" x="1024" y="640" width="448" height="192"/>
|
|
||||||
<object id="7" x="1152" y="320" width="192" height="320"/>
|
|
||||||
<object id="9" x="0" y="0" width="1184" height="16"/>
|
|
||||||
<object id="10" x="1184" y="0" width="416" height="16"/>
|
|
||||||
<object id="11" x="1584" y="0" width="16" height="960"/>
|
|
||||||
<object id="12" x="0" y="944" width="1600" height="16"/>
|
|
||||||
<object id="13" x="0" y="0" width="16" height="960"/>
|
|
||||||
</objectgroup>
|
|
||||||
</map>
|
|
@ -1,10 +1,12 @@
|
|||||||
function LoadMap(lvl)
|
function LoadMap(lvl)
|
||||||
|
ClearWalls()
|
||||||
|
|
||||||
local mapfilelocation = "maps/"
|
local mapfilelocation = "maps/"
|
||||||
local extention = ".lua"
|
local extention = ".lua"
|
||||||
local mapname = mapfilelocation .. "map" .. lvl .. extention
|
local mapname = mapfilelocation .. "map" .. lvl .. extention
|
||||||
|
|
||||||
GameMap = STI(mapname)
|
GameMap = STI(mapname)
|
||||||
Walls = {}
|
--Walls = {}
|
||||||
if GameMap.layers["Walls"] then
|
if GameMap.layers["Walls"] then
|
||||||
for _, obj in ipairs(GameMap.layers["Walls"].objects) do
|
for _, obj in ipairs(GameMap.layers["Walls"].objects) do
|
||||||
local wall = World:newRectangleCollider(obj.x, obj.y, obj.width, obj.height)
|
local wall = World:newRectangleCollider(obj.x, obj.y, obj.width, obj.height)
|
||||||
|
11
player.lua
11
player.lua
@ -3,19 +3,19 @@ cos = math.cos
|
|||||||
sin = math.sin --optimisation
|
sin = math.sin --optimisation
|
||||||
|
|
||||||
-- Constructor for the Player class
|
-- Constructor for the Player class
|
||||||
function Player:new(p, x, y, health, image, speed)
|
function Player:new(p, x, y, health, image, speed, max)
|
||||||
self.p = p
|
self.p = p
|
||||||
self.image = love.graphics.newImage(image)
|
self.image = love.graphics.newImage(image)
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.health = health
|
self.health = health
|
||||||
self.speed = speed
|
self.speed = speed
|
||||||
|
self.max = max
|
||||||
self.width = self.image:getWidth()
|
self.width = self.image:getWidth()
|
||||||
self.height = self.image:getHeight()
|
self.height = self.image:getHeight()
|
||||||
|
|
||||||
-- Collision Stuff
|
-- Collision Stuff
|
||||||
--self.collider = World:newRectangleCollider(x, y, 50, 62)
|
self.collider = World:newRectangleCollider(x, y, 64, 64)
|
||||||
self.collider = World:newCircleCollider(x, y, 24)
|
|
||||||
self.collider:setFixedRotation(true)
|
self.collider:setFixedRotation(true)
|
||||||
|
|
||||||
if self.p == 1 then
|
if self.p == 1 then
|
||||||
@ -61,13 +61,14 @@ function Player:handleKeys(up, down, left, right, dt)
|
|||||||
self.vx = cos(self.rotation) * (self.speed * dt)
|
self.vx = cos(self.rotation) * (self.speed * dt)
|
||||||
self.vy = sin(self.rotation) * (self.speed * dt)
|
self.vy = sin(self.rotation) * (self.speed * dt)
|
||||||
elseif love.keyboard.isDown(down) then
|
elseif love.keyboard.isDown(down) then
|
||||||
self.vx = cos(self.rotation) * (self.speed / 2 * dt) * -1
|
self.vx = cos(self.rotation) * (self.speed * dt) * -1
|
||||||
self.vy = sin(self.rotation) * (self.speed / 2 * dt) * -1
|
self.vy = sin(self.rotation) * (self.speed * dt) * -1
|
||||||
elseif love.keyboard.isDown(left) then
|
elseif love.keyboard.isDown(left) then
|
||||||
self.rotation = self.rotation - (self.rotSpeed * dt)
|
self.rotation = self.rotation - (self.rotSpeed * dt)
|
||||||
elseif love.keyboard.isDown(right) then
|
elseif love.keyboard.isDown(right) then
|
||||||
self.rotation = self.rotation + (self.rotSpeed * dt)
|
self.rotation = self.rotation + (self.rotSpeed * dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.collider:setLinearVelocity(self.vx, self.vy)
|
self.collider:setLinearVelocity(self.vx, self.vy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user