feat: add support for Sonic Battle maps
This commit is contained in:
parent
7fe34ed316
commit
2fe37fe9f2
3 changed files with 60 additions and 1 deletions
|
@ -6,11 +6,15 @@ local customMap = require "game.modules.world.maps"
|
||||||
function RadianceWorld:new(scene, maptype, mapname)
|
function RadianceWorld:new(scene, maptype, mapname)
|
||||||
local mappath = game.utils.getMapPath(maptype, mapname)
|
local mappath = game.utils.getMapPath(maptype, mapname)
|
||||||
RadianceWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
|
RadianceWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
|
||||||
|
|
||||||
|
self.mapname = mapname
|
||||||
end
|
end
|
||||||
|
|
||||||
function RadianceWorld:createMapController()
|
function RadianceWorld:createMapController()
|
||||||
if (self.maptype == "test") then
|
if (self.maptype == "test") then
|
||||||
customMap.Test(self)
|
customMap.Test(self)
|
||||||
|
elseif (self.maptype == "battle") then
|
||||||
|
customMap.Battle(self, self.maptype, self.mapname)
|
||||||
else
|
else
|
||||||
RadianceWorld.super.createMapController(self)
|
RadianceWorld.super.createMapController(self)
|
||||||
end
|
end
|
||||||
|
|
54
sonic-radiance.love/game/modules/world/maps/battle.lua
Normal file
54
sonic-radiance.love/game/modules/world/maps/battle.lua
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
local BaseMap = require "core.modules.world.maps.parent"
|
||||||
|
local BattleMap = BaseMap:extend()
|
||||||
|
|
||||||
|
function BattleMap:new(world, maptype, mapname)
|
||||||
|
BattleMap.super.new(self, world)
|
||||||
|
self:setPadding(0, 96, 0, 0)
|
||||||
|
self.directory = game.utils.getMapDirectory(maptype, mapname)
|
||||||
|
self.mappath = game.utils.getMapPath(maptype, mapname)
|
||||||
|
|
||||||
|
self.background = love.graphics.newImage(self.directory .. "background.png")
|
||||||
|
self.data = require(self.mappath)
|
||||||
|
self.assets = world.scene.assets
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:loadCollisions()
|
||||||
|
local w, h = self:getDimensions()
|
||||||
|
self.world:newCollision("floor", 0, 0, -16, w, h, 16)
|
||||||
|
for i, block in ipairs(self.data.blocks) do
|
||||||
|
self:addBlock(block[1], block[2], block[3], block[4], block[5], block[6])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:addBlock(x, y, w, h, top, bottom)
|
||||||
|
if (self.assets.images[top] == nil) then
|
||||||
|
self.assets:addImage(top, self.directory .. top .. ".png")
|
||||||
|
end
|
||||||
|
if (self.assets.images[bottom] == nil) then
|
||||||
|
self.assets:addImage(bottom, self.directory .. bottom .. ".png")
|
||||||
|
end
|
||||||
|
self.world.obj.collisions["textured"](self.world, x*2, y, 0, w*2, h, 64, top, bottom)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:getDimensions()
|
||||||
|
local w, h = self.background:getDimensions()
|
||||||
|
return w, (h/2)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:loadPlayers()
|
||||||
|
self.world:addPlayer(16, 16, 0, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:loadActors()
|
||||||
|
-- Empty Placeholder function
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:draw()
|
||||||
|
love.graphics.draw(self.background, 0, 0, 0, 1, 0.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleMap:drawParallax(x, y, w, h)
|
||||||
|
-- Empty Placeholder function
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleMap
|
|
@ -1,5 +1,6 @@
|
||||||
local customMap = {}
|
local customMap = {}
|
||||||
|
|
||||||
customMap.Test = require "game.modules.world.maps.test"
|
customMap.Test = require "game.modules.world.maps.test"
|
||||||
|
customMap.Battle = require "game.modules.world.maps.battle"
|
||||||
|
|
||||||
return customMap
|
return customMap
|
||||||
|
|
Loading…
Reference in a new issue