sonic-radiance/sonic-radiance.love/birb/modules/world/maps/tiled/init.lua

63 lines
1.4 KiB
Lua
Raw Normal View History

2021-05-05 08:30:32 +02:00
local Parent = require "birb.modules.world.maps.parent"
2021-03-23 13:32:48 +01:00
local TiledMap = Parent:extend()
2021-05-05 08:30:32 +02:00
local StiWrapper = require "birb.modules.world.maps.tiled.stiwrapper"
2021-03-23 13:32:48 +01:00
2021-05-05 08:30:32 +02:00
local TiledMixins = require "birb.modules.world.maps.tiled.mixins"
2021-03-23 13:32:48 +01:00
TiledMap:implement(TiledMixins)
function TiledMap:new(world, mapfile)
self.wrapper = StiWrapper(self, mapfile, 0, 0)
TiledMap.super.new(self, world)
self.supportTileCollision = true
2021-03-23 13:32:48 +01:00
self:setBackgroundColorFromTable(self.wrapper.sti.backgroundcolor)
self.mapname = self:getMapName(mapfile)
end
function TiledMap:getMapName(mapfile)
local filepath = utils.string.split(mapfile, "/")
local filenameMap = utils.string.split(filepath[#filepath], ".")
return filepath[#filepath - 1] .. "." .. filenameMap[1]
end
function TiledMap:getDimensions()
return self.wrapper:getDimensions()
end
function TiledMap:loadObjects()
2021-03-23 18:26:05 +01:00
--self.wrapper:loadObjects()
2021-03-23 13:32:48 +01:00
end
-- TILE FUNCTIONS
-- Get tiles
function TiledMap:haveTileTypeInRect(x, y, w, h, type)
return self.wrapper:haveTileTypeInRect(x, y, w, h, type)
end
-- UPDATE FUNCTION
-- Update or modify the map
function TiledMap:resize(w, h)
self.wrapper:resize(w, h)
end
function TiledMap:update(dt)
self.wrapper:update(dt)
end
-- DRAW FUNCTIONS
-- Handle drawing the wrapper
function TiledMap:drawUpperLayers()
self.wrapper:drawUpperLayers()
end
function TiledMap:drawLowerLayers()
self.wrapper:drawLowerLayers()
end
return TiledMap