diff --git a/assets/tileset/library.png b/assets/tileset/library.png index 9fcf3c5..4f84e85 100644 Binary files a/assets/tileset/library.png and b/assets/tileset/library.png differ diff --git a/data/levels/level1.lua b/data/levels/level1.lua index b769aa7..b62c11a 100644 --- a/data/levels/level1.lua +++ b/data/levels/level1.lua @@ -1,18 +1,21 @@ return { name = "test", tileset = tileset.library, + properties = { + darkness = false + }, tiles = { - { 1, 14, 14, 14, 14, 14, 14, 1, 14, 14, 14, 14, 14, 14, 14, 1}, - { 1, 4, 0, 0, 0, 0, 2, 14, 4, 0, 0, 0, 0, 0, 2, 1}, - { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, - { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, - { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, - { 1, 4, 0, 0, 0, 0, 2, 13, 4, 0, 0, 0, 0, 0, 2, 1}, - { 1, 13, 13, 13, 13, 13, 13, 1, 4, 0, 0, 0, 0, 0, 2, 1}, - { 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 2, 1}, - { 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + { 1, 14, 14, 14, 14, 14, 14, 1, 14, 14, 14, 14, 14, 14, 14, 1}, + { 1, 4, 0, 0, 0, 0, 2, 14, 4, 0, 0, 0, 0, 0, 2, 1}, + { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, + { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, + { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}, + { 1, 4, 0, 0, 0, 0, 2, 13, 4, 0, 0, 0, 0, 0, 2, 1}, + { 1, 13, 13, 13, 13, 13, 13, 1, 4, 0, 0, 0, 0, 0, 2, 1}, + { 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 2, 1}, + { 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1}, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }, objects = {} -} \ No newline at end of file +} diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index 14f76fd..e6985e0 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -45,6 +45,14 @@ o.canFall = true o.canFriction = true o.maskType = animation.moth_mask + o.anchorRespawn = { + x = o.pos.x, + y = o.pos.y + } + o.anchorRope = { + x = nil, + y = nil + } -- sprite o.target_offset = {x = 0, y = 0} @@ -166,6 +174,15 @@ function Player:DoPhysics() self.vel.y = 0 end end + + if self:isCollidingAt(self.pos.x, self.pos.y, LoadedObjects.Hazards) then + self:Respawn() + end +end + +function Player:Respawn() + self.pos.x = self.anchorRespawn.x + self.pos.y = self.anchorRespawn.y end function Player:HandleAnimation() diff --git a/data/scripts/game.lua b/data/scripts/game.lua index 96d71b4..6c5e4ca 100644 --- a/data/scripts/game.lua +++ b/data/scripts/game.lua @@ -53,7 +53,9 @@ function GameDraw() GameworldDrawPrepare() GameworldDrawBackground() GameworldDrawForeground() - GameworldDrawLighting() + if LevelData.properties.darkness then + GameworldDrawLighting() + end GameworldDrawParticles() GameworldDrawEntities() GameworldDrawEnd() diff --git a/data/scripts/in_out.lua b/data/scripts/in_out.lua index 031ca07..a0338e4 100644 --- a/data/scripts/in_out.lua +++ b/data/scripts/in_out.lua @@ -3,19 +3,28 @@ function ExportLevel(levelname, filename) filename = filename or "output.lua" filename = "Mothback/export/"..filename exportFile = io.open(filename, "w+") + if exportFile then - exportFile:write("return {") logPrint("Exporting level \"".. levelname .. "\"...") - exportFile:write("\n name = \"" .. levelname .. "\",") + exportFile:write("return {") + logPrint("- level name") + exportFile:write("\n name = \"" .. levelname .. "\",") + + logPrint("- tileset") for k, v in pairs(tileset) do if v == LevelData.tileset then exportFile:write("\n tileset = tileset." .. k .. ",") - logPrint("- tileset") end end - exportFile:write("\n tiles = {") + + logPrint("- properties") + exportFile:write("\n properties = {") + exportFile:write("\n darkness = true") + exportFile:write("\n },") + logPrint("- tiles") + exportFile:write("\n tiles = {") local rows = #LevelTiles for i = 1, #LevelTiles do exportFile:write("\n { ") @@ -33,10 +42,12 @@ function ExportLevel(levelname, filename) end logPrint(" - All rows 100%") exportFile:write("\n },") - exportFile:write("\n objects = {}") + logPrint("- objects") - exportFile:write("\n}") + exportFile:write("\n objects = {}") + logPrint("Exporting complete.") + exportFile:write("\n}") exportFile:close() end end diff --git a/data/scripts/level.lua b/data/scripts/level.lua index d23a146..022f2e9 100644 --- a/data/scripts/level.lua +++ b/data/scripts/level.lua @@ -338,6 +338,7 @@ function TileCreateObjects() LoadedObjects.Collisions = {} LoadedObjects.Platforms = {} LoadedObjects.Ladders = {} + LoadedObjects.Hazards = {} TileOptimizeObjects() @@ -625,6 +626,17 @@ function TileCreateObjects() ) table.insert(LoadedObjects.Platforms,plat) + elseif type == "bottom_hazard" then + + + local hazard = Collision:New( + base_x, + base_y + tileProperties.height * 12/16 * tileProperties.scale, + base_x + tileProperties.width * tileProperties.scale, + base_y + tileProperties.height * tileProperties.scale + ) + table.insert(LoadedObjects.Hazards,hazard) + end end end diff --git a/data/scripts/objects.lua b/data/scripts/objects.lua index e032316..0e5cf88 100644 --- a/data/scripts/objects.lua +++ b/data/scripts/objects.lua @@ -3,7 +3,8 @@ LoadedObjects = { Collisions = {}, Platforms = {}, - Ladders = {} + Ladders = {}, + Hazards = {} } -- level functions @@ -20,6 +21,10 @@ function LoadedObjects.DrawCollisions() for _, ladder in pairs(LoadedObjects.Ladders) do ladder:Draw(2) end + + for _, hazard in pairs(LoadedObjects.Hazards) do + hazard:Draw(1) + end end -- returns true if theres a collision at that point @@ -58,7 +63,8 @@ function SetCollisionFlags() local Check = { LoadedObjects.Collisions, LoadedObjects.Ladders, - LoadedObjects.Platforms + LoadedObjects.Platforms, + LoadedObjects.Hazards } for _, type in pairs(Check) do for _, object in pairs(type) do @@ -72,4 +78,11 @@ function SetCollisionFlags() platform.disable = true end end + for _, platform in pairs(LoadedObjects.Hazards) do + if main_Player.isOnGround then + platform.disable = true + else + platform.disable = false + end + end end diff --git a/data/tileset/library.lua b/data/tileset/library.lua index 0e37188..8e8cd14 100644 --- a/data/tileset/library.lua +++ b/data/tileset/library.lua @@ -82,15 +82,13 @@ properties[50] = { } properties[61] = { - overlay = {1}, - type = "emtpy", - depth = "background" + type = "bottom_hazard", + depth = "foreground" } properties[62] = { - overlay = {1}, - type = "emtpy", - depth = "background" + type = "top_hazard", + depth = "foreground" } return properties diff --git a/main.lua b/main.lua index 7450558..0d60ecc 100644 --- a/main.lua +++ b/main.lua @@ -63,7 +63,7 @@ function love.load() Fairy:New(200,88) --CursedBook:New(180,68) - love.audio.play(music.placeholder) + --love.audio.play(music.placeholder) end function love.update(dt)