summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-14 21:10:22 +0200
committerAki <nthirtyone@gmail.com>2017-09-14 21:10:22 +0200
commita8a581f3003c49f89eae85b5e57c278e7e3f835a (patch)
treedd4f8e18bf036a5a0d8127bb3e3f45eb7c9f3b68
parente316bd9c66ab29b424b55003b6565cbf7a7ede45 (diff)
downloadroflnauts-a8a581f3003c49f89eae85b5e57c278e7e3f835a.zip
roflnauts-a8a581f3003c49f89eae85b5e57c278e7e3f835a.tar.gz
roflnauts-a8a581f3003c49f89eae85b5e57c278e7e3f835a.tar.bz2
Prototyped trap map hazard (flames on 205)
-rw-r--r--assets/decorations/205-flames.pngbin0 -> 412 bytes
-rw-r--r--config/maps/205.lua3
-rw-r--r--not/World.lua77
3 files changed, 80 insertions, 0 deletions
diff --git a/assets/decorations/205-flames.png b/assets/decorations/205-flames.png
new file mode 100644
index 0000000..d1a0cf4
--- /dev/null
+++ b/assets/decorations/205-flames.png
Binary files differ
diff --git a/config/maps/205.lua b/config/maps/205.lua
index 1a9ae0e..d0aa1f8 100644
--- a/config/maps/205.lua
+++ b/config/maps/205.lua
@@ -13,6 +13,9 @@ return
},
create = {
{
+ flames = true
+ },
+ {
x = -36,
y = -48,
platform = "205-top"
diff --git a/not/World.lua b/not/World.lua
index 07843fe..e32c11d 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -83,6 +83,68 @@ function World:initLayers ()
end
end
+-- TODO: Move flames to separate class `Trap`.
+-- TODO: Make collisions for category 3 more customizable or create new category for traps/area effects.
+local
+function createFlame (self, x, y, mirror, timerIn, timerOut)
+ local trap = require("not.PhysicalBody")(x, y, self, "assets/decorations/205-flames.png")
+ trap:setAnimationsList({
+ default = {
+ [1] = love.graphics.newQuad(0, 0, 42, 19, 168, 19),
+ [2] = love.graphics.newQuad(42, 0, 42, 19, 168, 19),
+ frames = 2,
+ repeated = true
+ },
+ fadein = {
+ [1] = love.graphics.newQuad(84, 0, 42, 19, 168, 19),
+ [2] = love.graphics.newQuad(126, 0, 42, 19, 168, 19),
+ frames = 2,
+ repeated = false
+ },
+ fadeout = {
+ [1] = love.graphics.newQuad(126, 0, 42, 19, 168, 19),
+ [2] = love.graphics.newQuad(84, 0, 42, 19, 168, 19),
+ frames = 2,
+ repeated = false
+ }
+ })
+
+ -- hotfix for clash
+ trap.body:setUserData(trap)
+ trap.damage = function () end
+
+ local fixture = trap:addFixture({0,0, 41*mirror,0, 41*mirror,18, 0,18})
+ fixture:setCategory(3)
+ fixture:setMask(1)
+ local direction = "right"
+ if mirror < 0 then direction = "left" end
+ fixture:setUserData({0, direction})
+ fixture:setSensor(true)
+ trap:setBodyType("static")
+ trap.layer = self.layers.decorations
+
+ trap.getHorizontalMirror = function (self) return mirror end
+
+ trap.goToNextFrame = function (self)
+ if self.current.repeated or not (self.frame == self.current.frames) then
+ self.frame = (self.frame % self.current.frames) + 1
+ elseif self.current == self.animations.fadeout then
+ self:setAnimation("default")
+ self.hidden = true
+ else
+ self:setAnimation("default")
+ end
+ end
+
+ timerIn:register(trap.setBodyActive, trap, true)
+ timerIn:register(trap.setAnimation, trap, "fadein")
+ timerIn:register(function (self) trap.hidden = false end, trap)
+ timerOut:register(trap.setBodyActive, trap, false)
+ timerOut:register(trap.setAnimation, trap, "fadeout")
+
+ self:insertEntity(trap)
+end
+
--- Builds map using one of tables frin config files located in `config/maps/` directory.
-- TODO: Clean World@buildMap. Possibly explode into more methods.
function World:buildMap ()
@@ -124,6 +186,21 @@ function World:buildMap ()
self:insertEntity(cg)
cg:run(op.count, true)
end
+ -- TODO: Make flames and other traps more configurable through map config file.
+ if op.flames then
+ local timerIn = require("not.Timer")(10)
+ local timerOut = require("not.Timer")(5)
+
+ timerIn:register(timerOut.start, timerOut)
+ timerOut:register(timerIn.start, timerIn)
+
+ createFlame(self, -62, 16, 1, timerIn, timerOut)
+ createFlame(self, 63, 16, -1, timerIn, timerOut)
+
+ self:insertEntity(timerIn)
+ self:insertEntity(timerOut)
+ timerOut:start()
+ end
end
end