diff --git a/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back1.png b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back1.png new file mode 100644 index 0000000..da44d1c Binary files /dev/null and b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back1.png differ diff --git a/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back2.png b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back2.png new file mode 100644 index 0000000..1cb948f Binary files /dev/null and b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/back2.png differ diff --git a/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/init.lua b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/init.lua index d87d9dd..9c32698 100644 --- a/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/init.lua +++ b/sonic-radiance.love/datas/gamedata/maps/battle/ebeach/init.lua @@ -1,11 +1,15 @@ return { name = "Emerald Beach", blocks = { - {96, 48, 64, 32, "top1", "side2"}, - {112, 80, 32, 32, "top3", "side1"}, + {80, 64, 64, 32, "top1", "side2"}, + {96, 96, 32, 32, "top3", "side1"}, {192, 32, 96, 32, "top2", "side3"}, - {240, 112, 32, 64, "top4", "side1"}, - {112, 160, 32, 64, "top4", "side1"}, - {208, 224, 64, 32, "top5", "side2"}, + {224, 128, 32, 64, "top4", "side1"}, + {96, 176, 32, 64, "top4", "side1"}, + {192, 240, 64, 32, "top5", "side2"}, + }, + parallax = { + {0, 0, .5, 0, true, false, "back1"}, + {0, 10, 1, 1, true, false, "back2"}, } } diff --git a/sonic-radiance.love/game/modules/world/maps/battle.lua b/sonic-radiance.love/game/modules/world/maps/battle.lua index 9b6900a..3fd81e8 100644 --- a/sonic-radiance.love/game/modules/world/maps/battle.lua +++ b/sonic-radiance.love/game/modules/world/maps/battle.lua @@ -10,6 +10,8 @@ function BattleMap:new(world, maptype, mapname) self.background = love.graphics.newImage(self.directory .. "background.png") self.data = require(self.mappath) self.assets = world.scene.assets + + self:addParallax() end function BattleMap:loadCollisions() @@ -47,8 +49,49 @@ function BattleMap:draw() love.graphics.draw(self.background, 0, 0, 0, 1, 0.5) end +function BattleMap:addParallax() + self.parallax = {} + + for i,layerdata in ipairs(self.data.parallax) do + local layer = {} + layer.basex = layerdata[1] + layer.basey = layerdata[2] + layer.background = love.graphics.newImage(self.directory .. layerdata[7] .. ".png") + local w, h = layer.background:getDimensions() + layer.w = w + layer.h = h + + if (layerdata[5]) then + layer.repeatx = math.ceil(424/w + 1) + else + layer.repeatx = 1 + end + + if (layerdata[6]) then + layer.repeaty = math.ceil(240/h + 1) + else + layer.repeaty = 1 + end + + layer.decalx = layerdata[3] + layer.decaly = layerdata[4] + + table.insert(self.parallax, layer) + end +end + function BattleMap:drawParallax(x, y, w, h) - -- Empty Placeholder function + for i1, layer in ipairs(self.parallax) do + local x = math.floor((x)*layer.decalx) % layer.w + + for i=1, layer.repeatx do + for j=1, layer.repeaty do + local xx = math.floor(layer.basex + (layer.w * (i-1)) - x) + local yy = math.floor(layer.basey + (layer.h * (j-1)) - (y+96)*layer.decaly) + love.graphics.draw(layer.background, xx, yy) + end + end + end end return BattleMap