2020-01-03 19:41:30 +01:00
|
|
|
local Chunk = Object:extend()
|
|
|
|
|
|
|
|
function Chunk:new(map, data)
|
|
|
|
self.map = map
|
|
|
|
self.data = data
|
|
|
|
end
|
|
|
|
|
|
|
|
function Chunk:getFakeData()
|
|
|
|
local fakedata = {}
|
|
|
|
local emptyline = {00, 00, 00, 00, 00, 00, 00, 00}
|
|
|
|
fakedata.objects = {emptyline, emptyline, emptyline, emptyline, emptyline}
|
|
|
|
fakedata.terrain = {emptyline, emptyline, emptyline, emptyline, emptyline}
|
|
|
|
fakedata.grind = {emptyline, emptyline, emptyline, emptyline, emptyline}
|
|
|
|
|
|
|
|
return fakedata, false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Chunk:update(dt)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-01-12 00:02:06 +01:00
|
|
|
function Chunk:spawnGrounds(x)
|
|
|
|
for i=1, 5 do
|
|
|
|
for j=1, 8 do
|
|
|
|
if (self.data.terrain[i][j] ~= 3) then
|
|
|
|
self.map.world:newCollision("floor", x+(j-1)*31, (i-1)*20, -48, 31, 20, 48)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-03 19:41:30 +01:00
|
|
|
function Chunk:draw(x)
|
|
|
|
for i=1, 5 do
|
|
|
|
for j=1, 8 do
|
|
|
|
if (self.data.terrain[i][j] ~= 0) then
|
|
|
|
local tiley = (i-1)*20
|
|
|
|
local tilex = x + (j-1)*31 + (i-1)*10
|
|
|
|
local tileid = self.data.terrain[i][j]
|
|
|
|
|
|
|
|
self:drawTile(tilex, tiley, tileid)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Chunk:drawTile(x, y, type)
|
|
|
|
self.map.world.scene.assets.tileset["sptiles"]:drawTile(type, x, y)
|
|
|
|
end
|
|
|
|
|
|
|
|
return Chunk
|