feat(shootmap): add cliff drawing

This commit is contained in:
Kazhnuz 2019-08-02 16:49:50 +02:00
parent 52fdc3d681
commit 78d2f5ae93

View file

@ -10,7 +10,7 @@ function ShootMap:new(world, maptype, mapname)
ShootMap.super.new(self, world) ShootMap.super.new(self, world)
self:setPadding(0, 0, 0, 0) self:setPadding(0, 0, 0, 0)
self:generateTextures(1, "city") self:generateTextures(2, "tunnel")
end end
function ShootMap:loadCollisions() function ShootMap:loadCollisions()
@ -89,6 +89,7 @@ function ShootMap:addParallax(filename)
filename = backfolder .. filename filename = backfolder .. filename
self.texture.back1 = love.graphics.newImage(filename .. "-back.png") self.texture.back1 = love.graphics.newImage(filename .. "-back.png")
self.texture.back2 = love.graphics.newImage(filename .. "-fore.png") self.texture.back2 = love.graphics.newImage(filename .. "-fore.png")
self.texture.cliff = love.graphics.newImage(filename .. "-cliff.png")
end end
function ShootMap:drawParallax(x, y, w, h) function ShootMap:drawParallax(x, y, w, h)
@ -103,6 +104,7 @@ function ShootMap:drawParallax(x, y, w, h)
self:drawBorder(x, y + 10) self:drawBorder(x, y + 10)
self:drawBorder(x, y - 100) self:drawBorder(x, y - 100)
self:drawCliff(x, y - 110, w, h)
end end
function ShootMap:drawBackground(x, y, w, h) function ShootMap:drawBackground(x, y, w, h)
@ -130,4 +132,14 @@ function ShootMap:drawBorder(x, y)
end end
end end
function ShootMap:drawCliff(x, y, w, h)
local w2, h2 = self.texture.cliff:getDimensions()
local imax = math.ceil(w / w2) + 1
for i=1, imax do
local x1 = (x) % w2
love.graphics.draw(self.texture.cliff, (i-1)*w2 - x1, -y, 0, 1, 1, 0, 0)
end
end
return ShootMap return ShootMap