feat(maps): add a Shadow Shoot map loader

This commit is contained in:
Kazhnuz 2019-08-02 13:54:04 +02:00
parent 5968f82d52
commit 001c1a3d5a
6 changed files with 185 additions and 2 deletions

View file

@ -0,0 +1,46 @@
return {
["forest"] = {
name = "Jade Forest",
borders = 0,
tiles = 0,
background = "forest"
},
["city"] ={
name = "Diamond Highway",
borders = 1,
tiles = 1,
background = "city"
},
["tunnel"] ={
name = "Peridot Tunnel",
borders = 2,
tiles = 2,
background = "tunnel",
music = nil
},
["mountain"] ={
name = "Pearl Mountain",
borders = 3,
tiles = 3,
background = "mountain"
},
["hills"] ={
name = "Calcite Hills",
borders = 4,
tiles = 4,
background = "hills"
},
["bridge"] ={
name = "Carnelian Bridge",
borders = 5,
tiles = 5,
background = "bridge"
},
["castle"] ={
name = "Ametist Castle",
borders = 6,
tiles = 6,
background = "castle",
music = nil
},
}

View file

@ -21,7 +21,7 @@ function gameutils.getMapDirectory(maptype, mapname)
end
function gameutils.validateMapType(maptype)
local types = {"battle", "sti", "test"}
local types = {"battle", "sti", "test", "shoot"}
local validated = false
for i, type in ipairs(types) do

View file

@ -15,6 +15,9 @@ function RadianceWorld:createMapController()
customMap.Test(self)
elseif (self.maptype == "battle") then
customMap.Battle(self, self.maptype, self.mapname)
elseif (self.maptype == "shoot") then
customMap.Shoot(self, self.maptype, self.mapname)
self.cameras:lockY(4)
else
RadianceWorld.super.createMapController(self)
end

View file

@ -2,5 +2,6 @@ local customMap = {}
customMap.Test = require "game.modules.world.maps.test"
customMap.Battle = require "game.modules.world.maps.battle"
customMap.Shoot = require "game.modules.world.maps.shoot"
return customMap

View file

@ -0,0 +1,133 @@
local BaseMap = require "core.modules.world.maps.parent"
local ShootMap = BaseMap:extend()
local TILESIZE = 31
local TESTZONE = "forest"
local zoneDatas = require "datas.gamedata.maps.shoot.zones"
function ShootMap:new(world, maptype, mapname)
ShootMap.super.new(self, world)
self:setPadding(0, 0, 0, 0)
self:generateTextures(1)
end
function ShootMap:loadCollisions()
local w, h = self:getDimensions()
self.world:newCollision("floor", 0, 0, -16, w, h, 16)
end
function ShootMap:addBlock(x, y, w, h, top, bottom)
-- Empty Placeholder function
end
function ShootMap:getDimensions()
return 3000, 100
end
function ShootMap:loadPlayers()
self.world:addPlayer(16, 50, 0, 1)
end
function ShootMap:loadActors()
-- Empty Placeholder function
end
function ShootMap:generateTextures(tile)
self.texture = {}
self.texture.floor = self:generateFloor(tile)
self.texture.border = love.graphics.newImage("assets/backgrounds/borders.png")
self.quads = {}
local w, h = self.texture.border:getDimensions()
self.quads.borders = love.graphics.newQuad(0, tile*10, 80, 10, w, h)
self:addParallax("city")
end
function ShootMap:generateFloor(tile)
local canvas = love.graphics.newCanvas(31*16, 100)
local tile = tile or 1
local tileTexture = love.graphics.newImage("assets/backgrounds/normaltile.png")
local tileQuad = {}
local w, h = tileTexture:getDimensions()
tileQuad[1] = love.graphics.newQuad( 0, tile*24, 40, 24, w, h)
tileQuad[2] = love.graphics.newQuad(40, tile*24, 40, 24, w, h)
love.graphics.setCanvas( canvas )
for i=1, 5 do
for j=0, 18 do
local tiley = (i-1)*20 - 4
local tilex = (j-2)*31 + (i-1)*10
local variant = 1 + ((i + j) % 2)
love.graphics.draw(tileTexture, tileQuad[variant], tilex, tiley)
end
end
love.graphics.setCanvas( )
local imagedata = canvas:newImageData()
local texture = love.graphics.newImage( imagedata )
imagedata:release()
canvas:release()
return texture
end
function ShootMap:draw()
for i=1, 10 do
--love.graphics.draw(self.texture.floor, ((i-1)*31*16), 0)
end
end
function ShootMap:addParallax(filename)
-- Empty Placeholder function
local filename = filename or "forest"
local backfolder = "assets/backgrounds/parallax/"
filename = backfolder .. filename
self.texture.back1 = love.graphics.newImage(filename .. "-back.png")
self.texture.back2 = love.graphics.newImage(filename .. "-fore.png")
end
function ShootMap:drawParallax(x, y, w, h)
self:drawBackground(x, y, w, h)
self:drawForeground(x, y + 10, w, h)
local w2, _ = self.texture.floor:getDimensions()
for i=1, 2 do
local x2 = x % w2
love.graphics.draw(self.texture.floor, ((i-1)*31*16)-x2, -y)
end
self:drawBorder(x, y + 10)
self:drawBorder(x, y - 100)
end
function ShootMap:drawBackground(x, y, w, h)
local w2, h2 = self.texture.back1:getDimensions()
local imax = math.ceil(w / w2) + 1
for i=1, imax do
local x1 = (x / 5) % w2
love.graphics.draw(self.texture.back1, (i-1)*w2 - x1, 0, 0, 1, 1, 0, 0)
end
end
function ShootMap:drawForeground(x, y, w, h)
local w2, h2 = self.texture.back2:getDimensions()
local imax = math.ceil(w / w2) + 1
for i=1, imax do
local x1 = (x / 2) % w2
love.graphics.draw(self.texture.back2, (i-1)*w2 - x1, -y, 0, 1, 1, 0, h2)
end
end
function ShootMap:drawBorder(x, y)
for i=1, 7 do
local x2 = x % 80
love.graphics.draw(self.texture.border, self.quads.borders, (i-1)*80 - x2, -y, 0, 1, 1)
end
end
return ShootMap

View file

@ -33,7 +33,7 @@ function MovePlayer:new(playerNumber, cameraMode)
MovePlayer.super.new(self)
self.assets:batchImport("scenes.test_scene.assets")
World(self, "battle", "ebeach")
World(self, "shoot", "ebeach")
self.world:setPlayerNumber(playerNumber)
self.world.cameras:setMode(cameraMode)