feat: dumb test map system

This commit is contained in:
Kazhnuz 2020-04-25 12:15:21 +02:00
parent 318e297095
commit a4a1bc94a3
2 changed files with 16 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

View file

@ -3,21 +3,18 @@ local TestMap = BaseMap:extend()
function TestMap:new(world) function TestMap:new(world)
TestMap.super.new(self, world) TestMap.super.new(self, world)
self:setPadding(0, 96, 0, 0) --self:setPadding(0, 0, 0, 0)
self.background = love.graphics.newImage("assets/backgrounds/parallax/test-back.png") self.background = love.graphics.newImage("assets/backgrounds/dumbtestmap.png")
end end
function TestMap:loadCollisions() function TestMap:loadCollisions()
self.world:newCollision("wall", 0, 0, -16, 8*64, 8*32, 16) local w, h = self:getDimensions()
self.world:newCollision("wall", 64*1, 32*1, 0, 64*1, 32*3, 48) self.world:newCollision("floor", 0, 0, -16, w, h, 16)
self.world:newCollision("wall", 64*4, 32*1, 0, 64*3, 32*1, 48)
self.world:newCollision("wall", 64*6, 32*4, 0, 64*1, 32*3, 48)
self.world:newCollision("wall", 64*1, 32*6, 0, 64*3, 32*1, 48)
end end
function TestMap:getDimensions() function TestMap:getDimensions()
return 8*64, 8*32 return self.background:getDimensions()
end end
function TestMap:loadPlayers() function TestMap:loadPlayers()
@ -30,19 +27,20 @@ end
function TestMap:draw() function TestMap:draw()
-- Empty Placeholder function -- Empty Placeholder function
love.graphics.draw(self.background, 0, 0)
end end
function TestMap:drawParallax(x, y, w, h) function TestMap:drawParallax(x, y, w, h)
local imax, jmax = (w/32)+1, (h/32)+1 -- local imax, jmax = (w/32)+1, (h/32)+1
local x, y = x or 0, y or 0 -- local x, y = x or 0, y or 0
local x = math.floor(x/4) % 32 -- local x = math.floor(x/4) % 32
local y = math.floor((y+96)/6) % 32 -- local y = math.floor((y+96)/6) % 32
--
for i=0, math.ceil(imax) do -- for i=0, math.ceil(imax) do
for j=0, math.ceil(jmax) do -- for j=0, math.ceil(jmax) do
love.graphics.draw(self.background, (i-1)*32-x, (j-1)*32-y) -- love.graphics.draw(self.background, (i-1)*32-x, (j-1)*32-y)
end -- end
end -- end
end end
return TestMap return TestMap