Add win condition
This commit is contained in:
parent
61377bb442
commit
700b0000ac
55
main.lua
55
main.lua
|
@ -4,7 +4,7 @@ wind = require "lib/windfield"
|
|||
stalker = require "lib/STALKER-X"
|
||||
|
||||
downwall = 1; rightwall = 2; leftwall = 3
|
||||
mainmenu = 0; game = 1; gameover = 2; pause = 3
|
||||
mainmenu = 0; game = 1; gameover = 2; pause = 3; youwin = 4
|
||||
|
||||
world = wind.newWorld(0, 40, true)
|
||||
|
||||
|
@ -30,6 +30,7 @@ function love.update(dt)
|
|||
if(mode == mainmenu) then mainmenu_update(dt)
|
||||
elseif(mode == game) then game_update(dt)
|
||||
elseif(mode == gameover) then gameover_update(dt)
|
||||
elseif(mode == youwin) then youwin_update(dt)
|
||||
elseif(mode == pause) then pause_update(dt)
|
||||
end
|
||||
camera:update(dt)
|
||||
|
@ -41,6 +42,7 @@ function love.draw()
|
|||
if(mode == mainmenu) then mainmenu_draw()
|
||||
elseif(mode == game) then game_draw()
|
||||
elseif(mode == gameover) then gameover_draw()
|
||||
elseif(mode == youwin) then youwin_draw()
|
||||
elseif(mode == pause) then pause_draw()
|
||||
end
|
||||
camera:detach()
|
||||
|
@ -57,6 +59,7 @@ function love.keypressed(key)
|
|||
if(mode == mainmenu) then mainmenu_keypressed(key)
|
||||
elseif(mode == game) then game_keypressed(key)
|
||||
elseif(mode == gameover) then gameover_keypressed(key)
|
||||
elseif(mode == youwin) then youwin_keypressed(key)
|
||||
elseif(mode == pause) then pause_keypressed(key)
|
||||
end
|
||||
end
|
||||
|
@ -66,6 +69,7 @@ function love.keyreleased (key)
|
|||
if(mode == mainmenu) then mainmenu_keyreleased(key)
|
||||
elseif(mode == game) then game_keyreleased(key)
|
||||
elseif(mode == gameover) then gameover_keyreleased(key)
|
||||
elseif(mode == youwin) then youwin_keyreleased(key)
|
||||
elseif(mode == pause) then pause_keyreleased(key)
|
||||
end
|
||||
end
|
||||
|
@ -89,7 +93,7 @@ function mainmenu_load ()
|
|||
frontMenu_init()
|
||||
|
||||
camera = stalker()
|
||||
map = Map:new("maps/menu.lua")
|
||||
map = Map:new("maps/sys/menu.lua")
|
||||
player.following = true
|
||||
end
|
||||
|
||||
|
@ -243,7 +247,7 @@ end
|
|||
|
||||
|
||||
function gameover_keypressed(key)
|
||||
if (key == "return") then
|
||||
if (key == "return" or key == "space") then
|
||||
camera:fade(.2, {0,0,0,1}, function() game_load() end)
|
||||
elseif (key == "escape") then
|
||||
mainmenu_load()
|
||||
|
@ -256,6 +260,45 @@ end
|
|||
|
||||
|
||||
|
||||
-- YOUWIN STATE
|
||||
----------------------------------------
|
||||
function youwin_load ()
|
||||
mode = youwin
|
||||
|
||||
camera = stalker()
|
||||
map = Map:new("maps/sys/win.lua")
|
||||
end
|
||||
|
||||
|
||||
function youwin_update(dt)
|
||||
world:update(dt)
|
||||
player:update(dt)
|
||||
end
|
||||
|
||||
|
||||
function youwin_draw ()
|
||||
map:draw()
|
||||
player:draw()
|
||||
|
||||
camera:detach()
|
||||
love.graphics.draw(love.graphics.newText(r_ttf,
|
||||
"monkey happy!\n"), 200, 200, 0, 3, 3)
|
||||
camera:attach()
|
||||
end
|
||||
|
||||
|
||||
function youwin_keypressed(key)
|
||||
if (key == "return" or key == "space" or key == "escape") then
|
||||
mainmenu_load()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function youwin_keyreleased(key)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- GAME STATE
|
||||
----------------------------------------
|
||||
function game_load(mapfile)
|
||||
|
@ -537,6 +580,11 @@ function Monk:makeCollisionCallback (i)
|
|||
self.onGround[i] = rightwall
|
||||
end
|
||||
|
||||
elseif (collision1.collision_class == "monk"
|
||||
and collision2.collision_class == "banana")
|
||||
then
|
||||
youwin_load()
|
||||
|
||||
elseif (collision1.collision_class == "monk"
|
||||
and collision2.collision_class == "button")
|
||||
then
|
||||
|
@ -561,6 +609,7 @@ Banana = class('Banana')
|
|||
function Banana:initialize(x, y)
|
||||
self.sprite = love.graphics.newImage("art/sprites/banana.png")
|
||||
self.collider = world:newRectangleCollider(x, y, 16, 16);
|
||||
self.collider:setCollisionClass('banana')
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
return {
|
||||
version = "1.4",
|
||||
luaversion = "5.1",
|
||||
tiledversion = "1.4.3",
|
||||
orientation = "orthogonal",
|
||||
renderorder = "right-down",
|
||||
width = 50,
|
||||
height = 50,
|
||||
tilewidth = 16,
|
||||
tileheight = 16,
|
||||
nextlayerid = 4,
|
||||
nextobjectid = 33,
|
||||
properties = {},
|
||||
tilesets = {},
|
||||
layers = {
|
||||
{
|
||||
type = "objectgroup",
|
||||
draworder = "topdown",
|
||||
id = 2,
|
||||
name = "Object Layer 1",
|
||||
visible = true,
|
||||
opacity = 1,
|
||||
offsetx = 0,
|
||||
offsety = 0,
|
||||
properties = {},
|
||||
objects = {
|
||||
{
|
||||
id = 2,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 38.932,
|
||||
y = 306.814,
|
||||
width = 14.6488,
|
||||
height = 242.519,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 4,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 55.2085,
|
||||
y = 537.94,
|
||||
width = 524.102,
|
||||
height = 11.3935,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 6,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 581.752,
|
||||
y = 306,
|
||||
width = 14.6488,
|
||||
height = 242.52,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 27,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "polygon",
|
||||
x = 800,
|
||||
y = 530.242,
|
||||
width = 0,
|
||||
height = 0,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
polygon = {
|
||||
{ x = 0, y = 0 },
|
||||
{ x = -360.606, y = 269.697 },
|
||||
{ x = -6.06061, y = 266.667 }
|
||||
},
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 28,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 46.6665,
|
||||
y = 791.333,
|
||||
width = 66.6667,
|
||||
height = 14.6667,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 29,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 177.333,
|
||||
y = 790,
|
||||
width = 105.333,
|
||||
height = 16,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
},
|
||||
{
|
||||
id = 30,
|
||||
name = "",
|
||||
type = "",
|
||||
shape = "rectangle",
|
||||
x = 346.667,
|
||||
y = 788.667,
|
||||
width = 54.6667,
|
||||
height = 16,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type = "objectgroup",
|
||||
draworder = "topdown",
|
||||
id = 3,
|
||||
name = "Object Layer 2",
|
||||
visible = true,
|
||||
opacity = 1,
|
||||
offsetx = 0,
|
||||
offsety = 0,
|
||||
properties = {},
|
||||
objects = {
|
||||
{
|
||||
id = 31,
|
||||
name = "",
|
||||
type = "spawn",
|
||||
shape = "point",
|
||||
x = 321.333,
|
||||
y = 484,
|
||||
width = 0,
|
||||
height = 0,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {
|
||||
["count"] = 10
|
||||
}
|
||||
},
|
||||
{
|
||||
id = 32,
|
||||
name = "",
|
||||
type = "respawn",
|
||||
shape = "point",
|
||||
x = 330.667,
|
||||
y = 2.66667,
|
||||
width = 0,
|
||||
height = 0,
|
||||
rotation = 0,
|
||||
visible = true,
|
||||
properties = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Ŝarĝante…
Reference in New Issue