feat: backport code from bluestreak

It'll give us the following features
- Support for autorun in shoot-style maps
- Pause menu in subgames
- Chunk in shoot maps
- Rings
This commit is contained in:
Kazhnuz 2020-08-16 10:52:00 +02:00
parent 849d3ce537
commit 70ed18202d
27 changed files with 804 additions and 123 deletions

View file

@ -0,0 +1,53 @@
return {
parts = {
[0] = {{"self",{01,00,00,00}}, {"self",{00,00,00,00}}}
},
chunks = {
[0] = {
terrain = {
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00}
},
objects = {
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00}
},
grind = {
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00}
}
},
[1] = {
terrain = {
{00,00,01,00,00,00,04,03},
{00,00,00,01,00,00,00,03},
{00,00,02,02,02,02,02,03},
{00,00,00,01,00,00,00,03},
{00,00,01,00,00,00,04,03}
},
objects = {
{00,00,00,01,01,01,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00},
{00,00,00,02,02,02,00,00}
},
grind = {
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,01,03},
{00,00,01,02,02,02,03,00},
{00,00,00,00,00,00,00,00},
{00,00,00,00,00,00,00,00}
}
},
}
}

View file

@ -0,0 +1,13 @@
return {
[0] = {
setDashTo = nil,
changeSpd = false,
max = 1,
acc = 1,
spd = 0,
groundbellow = true,
springPow = 0,
playSFX = nil,
hazard = false,
}
}

View file

@ -0,0 +1,14 @@
return {
datas = {
zone = "forest",
bypass_zone = true,
bypass_data = {
tiles = nil,
background = nil
}
},
layout = {{"self", {00}}, {"basics", {00, 00}},},
parts = {
[0] = { {"basics", {01}}, {"basics", {00}}, }
}
}

View file

@ -0,0 +1,21 @@
return {
["textures"] = {
{"shadow", "assets/sprites/shadow.png"}
},
["sprites"] = {
{"ring", "assets/sprites/items/ring"}
},
["imagefonts"] = {
{"menu", "assets/gui/fonts/SA2font"},
{"numbers", "assets/gui/fonts/hudnumbers"},
{"smallnumbers", "assets/gui/fonts/hudsmallnumbers"},
},
["sfx"] = {
{"navigate", "assets/sfx/menus/beep.wav"},
{"confirm", "assets/sfx/menus/select.wav"},
{"cancel", "assets/sfx/menus/back.wav"},
},
["tilesets"] = {
{"sptiles", "assets/backgrounds/specialtile"}
}
}

View file

@ -0,0 +1,83 @@
Scene = require("core.modules.scenes")
local PlayStyle = Scene:extend()
local PauseMenu = require("game.modules.subgames.pause")
local TestWorld = require("game.modules.world.parent")
function PlayStyle:new(supportedLevels, missionfile)
PlayStyle.super.new(self)
self.timer = 0
self.assets:batchImport("game.modules.gui.assets")
self.assets:batchImport("game.modules.subgames.assets")
--self:loadMissionFile(supportedLevels, missionfile)
PauseMenu(self)
self:initWorld()
self:initMission()
self:initCharacters()
self:startLevel()
end
function PlayStyle:loadMissionFile(supportedLevels, missionfile)
self.mission = require("datas.gamedata.missions." .. missionfile)
self.assets:setMusic("assets/music/" .. self.mission.music)
end
function PlayStyle:initWorld()
TestWorld(self)
end
function PlayStyle:initMission()
-- NOTHING
end
function PlayStyle:initCharacters()
self.world:setPlayerNumber(1)
self.world.cameras:setMode("split")
end
function PlayStyle:getCharacterName(charID)
return self.characterList[charID]
end
function PlayStyle:update(dt)
PlayStyle.super.update(self, dt)
if self.menusystem.menus["pauseMenu"].isActive == false then
self.timer = self.timer + dt
end
local keys = self:getKeys(1);
if keys["start"].isPressed then
if not (self.menusystem.menus["pauseMenu"].isActive) then
self.menusystem.menus["pauseMenu"].isActive = true
self.menusystem.menus["pauseMenu"].isVisible = true
self.menusystem.menus["pauseMenu"]:getFocus()
self.assets.isActive = false
self.world.isActive = false
else
self.menusystem.menus["pauseMenu"].isActive = false
self.menusystem.menus["pauseMenu"].isVisible = false
self.assets.isActive = true
self.world.isActive = true
end
end
end
function PlayStyle:startLevel()
self.world:loadMap()
--self.assets:playMusic()
end
function PlayStyle:restartLevel()
self.world:reset()
end
function PlayStyle:exitLevel()
scenes.title()
end
return PlayStyle

View file

@ -0,0 +1,76 @@
local ListBox = require "core.modules.menusystem.listbox"
local PauseMenu = ListBox:extend()
local Widget = require "core.modules.menusystem.widgets"
local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend()
local gui = require "game.modules.gui"
function PauseMenu:new(subgame)
local height, width, x, y
height = 72
width = 128
x = 424/2 - width/2
y = 240/2 - height/2
PauseMenu.super.new(self, subgame.menusystem, "pauseMenu", x, y, width, height, 3)
self.subgame = subgame
self:setSound(self.subgame.assets.sfx["navigate"])
self.isActive = false
self.isVisible = false
local font = self.subgame.assets.fonts["menu"]
self.textbox = gui.newTextBox("assets/gui/dialogbox.png", width+16, height+16)
ResumeWidget(self, font)
RestartWidget(self, font)
ExitWidget(self, font)
end
function PauseMenu:draw()
love.graphics.draw(self.textbox, self.x-8, self.y-8)
PauseMenu.super.draw(self)
end
--- MENU WIDGETS
function ResumeWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "resume")
end
function ResumeWidget:action()
self.menu.isActive = false
self.menu.isVisible = false
self.menu.subgame.world.isActive = true
self.menu.subgame.assets.isActive = true
self.menu.subgame:flushKeys()
end
function RestartWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "restart")
end
function RestartWidget:action()
self.menu.subgame:restartLevel()
self.menu.isActive = false
self.menu.isVisible = false
self.menu.subgame.world.isActive = true
self.menu.subgame.assets.isActive = true
self.menu.subgame:flushKeys()
end
function ExitWidget:new(menu, font)
ExitWidget.super.new(self, menu, font, "exit")
end
function ExitWidget:action()
self.menu.subgame:exitLevel()
end
return PauseMenu

View file

@ -0,0 +1,29 @@
local Base = require "core.modules.world.actors.actor3D"
local FakeFloor = Base:extend()
function FakeFloor:new(world, x, y, z, w, h, d)
FakeFloor.super.new(self, world, "fakefloor", x, y, z, w, h, d, false)
self:setDebugColor(0,0,0)
self.boxes.Base(self, w, h, d, false)
end
function FakeFloor:update(dt)
end
function FakeFloor:draw()
local drawx, drawy, drawz = self.x, self.y, self.z
if (self.world.maptype == "shoot") then
drawx = drawx + math.floor(drawy/2)
end
self:drawStart()
if (self.box ~= nil) then
self.box:draw(drawx, drawy, drawz)
else
local x, y = math.floor(drawx), math.floor(drawy - drawz - self.d + (self.h/2))
self:drawSprite(x, y)
end
self:drawEnd()
end
return FakeFloor

View file

@ -0,0 +1,29 @@
local Base = require "core.modules.world.actors.actor3D"
local Floor = Base:extend()
function Floor:new(world, x, y, z, w, h, d)
Floor.super.new(self, world, "wall", x, y, z, w, h, d, true)
self:setDebugColor(0,0,0)
self.boxes.Base(self, w, h, d, false)
end
function Floor:update(dt)
end
function Floor:draw()
local drawx, drawy, drawz = self.x, self.y, self.z
if (self.world.maptype == "shoot") then
drawx = drawx + math.floor(drawy/2)
end
self:drawStart()
if (self.box ~= nil) then
self.box:draw(drawx, drawy, drawz)
else
local x, y = math.floor(drawx), math.floor(drawy - drawz - self.d + (self.h/2))
self:drawSprite(x, y)
end
self:drawEnd()
end
return Floor

View file

@ -1,14 +0,0 @@
local Base = require "core.modules.world.actors.actor3D"
local Floor = Base:extend()
function Floor:new(world, x, y, z, w, h, d)
Floor.super.new(self, world, "wall", x, y, z, w, h, d, true)
self:setDebugColor(0,0,0)
self.boxes.Base(self, w, h, d, false)
end
function Floor:update(dt)
end
return Floor

View file

@ -3,14 +3,20 @@ local Obj = {}
-- On charge toutes les différentes types d'acteurs
local cwd = (...):gsub('%.init$', '') .. "."
Obj.Player = require(cwd .. "player")
Obj.Ring = require(cwd .. "items.ring")
Obj.index = {}
Obj.index["player"] = Obj.Player
Obj.collisions = {}
Obj.collisions["wall"] = require(cwd .. "wall")
Obj.collisions["invisible"] = require(cwd .. "invisible")
Obj.collisions["floor"] = require(cwd .. "floor")
Obj.collisions["textured"] = require(cwd .. "textured")
Obj.collisions["wall"] = require(cwd .. "collisions.wall")
Obj.collisions["invisible"] = require(cwd .. "collisions.invisible")
Obj.collisions["floor"] = require(cwd .. "collisions.floor")
Obj.collisions["textured"] = require(cwd .. "collisions.textured")
Obj.collisions["fakefloor"] = require(cwd .. "collisions.fakefloor")
Obj.index = {}
Obj.index[01] = Obj.Ring
Obj.index[02] = Obj.Ring
return Obj

View file

@ -0,0 +1,12 @@
local Parent = require "game.modules.world.actors.parent"
local Collectible = Parent:extend()
function Collectible:new(world, x, y, z, w, h, d)
Collectible.super.new(self, world, "collectible", x, y, z, w, h, d, false)
end
function Collectible:getPicked(player)
self:destroy()
end
return Collectible

View file

@ -0,0 +1,17 @@
local cwd = (...):gsub('%.ring$', '') .. "."
local Collectible = require(cwd .. "collectible")
local Ring = Collectible:extend()
function Ring:new(world, x, y, z)
Ring.super.new(self, world, x, y, z+6, 16, 10, 16)
self:setSprite("ring", 0, 0)
end
function Ring:getPicked(player)
player:setRing(1, true)
player:setScore(10, true)
self:destroy()
end
return Ring

View file

@ -7,11 +7,32 @@ function Parent:new(world, type, x, y, z, w, h, d, isSolid)
end
function Parent:draw()
Parent.super.draw(self)
--self:drawMainHitbox()
local drawx, drawy, drawz = self.x, self.y, self.z
if (self.world.maptype == "shoot") then
drawx = drawx + math.floor(drawy/2)
end
self:drawStart()
if (self.box ~= nil) then
self.box:draw(drawx, drawy, drawz)
else
local x, y = math.floor(drawx), math.floor(drawy - drawz - self.d + (self.h/2))
if (math.floor(drawz) < -2) and (self.world.maptype == "shoot") then
core.screen:setScissor(0, 0, 424, 58+drawy/2)
self:drawSprite(x, y)
core.screen:resetScissor()
else
self:drawSprite(x, y)
end
end
self:drawEnd()
end
function Parent:drawShadow(x, y)
local x = x or 0
local y = y or 0
if (self.world.maptype == "shoot") then
x = x + math.floor(y/2)
end
self.assets.images["shadow"]:draw(x-4, y+4)
end

View file

@ -8,32 +8,28 @@ function Player:new(world, x, y, z, id)
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
self:setGravity(480*2)
self:init()
self.action = "normal"
self.rings = 0
self.score = 0
end
function Player:init()
self.charName = game.characters:getActiveCharacter()
self.assets:addSprite(self.charName, "datas/gamedata/characters/" .. self.charName .. "/sprites")
self:setSprite(self.charName, 8, 10)
self:cloneSprite()
self.guiborder = game.gui.newBorder(424, 20, 6)
self.emblem = Emblem(game.characters:getActiveCharacterData(), self.scene)
self.action = "normal"
self.guiborder = game.gui.newBorder(424, 20, 6)
end
function Player:updateStart(dt)
self.xfrc, self.yfrc = 480*3, 480*3
if self.keys["up"].isDown then
self.ysp = -160
end
if self.keys["down"].isDown then
self.ysp = 160
end
if self.keys["left"].isDown then
self.xsp = -160
end
if self.keys["right"].isDown then
self.xsp = 160
end
self:basicMovements()
if self.keys["A"].isDown and (self.onGround) then
self.zsp = 280*1.33
@ -44,6 +40,33 @@ function Player:updateStart(dt)
end
end
function Player:basicMovements()
if self.keys["up"].isDown then
self.ysp = -160
end
if self.keys["down"].isDown then
self.ysp = 160
end
if (self.world.autorun == true) then
self.xsp = 160
else
if self.keys["left"].isDown then
self.xsp = -160
end
if self.keys["right"].isDown then
self.xsp = 160
end
end
end
function Player:collisionResponse(collision)
if collision.other.type == "collectible" then
collision.other.owner:getPicked(self)
end
end
function Player:animationEnded(name)
end
@ -98,4 +121,18 @@ function Player:drawHUD(id)
self.emblem:draw(424 - 40, 12)
end
function Player:setRing(value, isRelative)
if (isRelative == false) then
self.rings = 0
end
self.rings = self.rings + value
end
function Player:setScore(value, isRelative)
if (isRelative == false) then
self.score = 0
end
self.score = self.score + value
end
return Player

View file

@ -0,0 +1,17 @@
local ParentWorld = require "game.modules.world.parent"
local BattleWorld = ParentWorld:extend()
local customMap = require "game.modules.world.maps"
function BattleWorld:new(scene, mapname)
local mappath = game.utils.getMapPath("battle", mapname)
BattleWorld.super.new(self, scene, "battle", mapname)
self.mapname = mapname
end
function BattleWorld:createMapController()
customMap.Battle(self, self.maptype, self.mapname)
end
return BattleWorld

View file

@ -7,17 +7,130 @@ local TESTZONE = "forest"
local zoneDatas = require "datas.gamedata.maps.shoot.zones"
local Background = require "game.modules.drawing.parallaxBackground"
local Chunk = require "game.modules.world.maps.tools.chunk"
function ShootMap:new(world, maptype, mapname)
ShootMap.super.new(self, world)
self:setPadding(0, 0, 0, 0)
self.parallaxBackground = Background(world.scene, 5, 1, "tunnel")
self:getLevelData(mapname)
self.parallaxBackground = Background(world.scene, 5, 1, self.datas.background)
self.layout = {}
self.chunklist = {}
self.width = 0
end
function ShootMap:updateWidth()
self.size = #self.layout * 8
self.width = self.size * 31
end
function ShootMap:getLevelData(mapname)
local file = file or "testlevel.test1"
local level = require("datas.gamedata.maps.shoot." .. file)
self.zone = level.datas.zone
local currentZone_datas = zoneDatas[self.zone]
local bypass_data = level.datas.bypass_data
self.datas = {}
if (level.datas.bypass_zone) then
self.datas.tiles = bypass_data.tiles or currentZone_datas.tiles
self.datas.background = bypass_data.background or currentZone_datas.background
else
self.datas = currentZone_datas
end
self.datas.layout = level.layout
self.datas.parts = level.parts
end
function ShootMap:loadCollisions()
self:loadLayout();
local w, h = self:getDimensions()
self.world:newCollision("floor", 0, 0, -16, w, h, 16)
--self.world:newCollision("floor", 0, 0, -16, w, h, 16)
for i, chunkname in ipairs(self.layout) do
self.chunklist[chunkname]:spawnGrounds((i-1)*31*8)
self.chunklist[chunkname]:spawnObjects((i-1)*31*8)
end
local CHUNKSIZE = TILESIZE*8
self.world:newCollision("fakefloor", -CHUNKSIZE, 0, -48, self.width+CHUNKSIZE*2, 200, 48)
end
function ShootMap:loadLayout()
self.layout = {}
-- [ShootMap].datas.layout est un tableau composée d'une série de tableau,
-- chacuns en deux partie : le premier (part[1]) contient le nom du fichier
-- où se trouve des partie de niveau, et la seconde partie (part[2]) une liste
-- d'identifiant de partie de niveau à rajouter.
-- Ce format permet de simplifier l'écriture de layout, si on a besoin de
-- plusieur partie de niveau se trouvant dans le même fichier.
for i, partContainer in ipairs(self.datas.layout) do
for j, part in ipairs(partContainer[2]) do
self:addPart(partContainer[1], part)
end
end
end
function ShootMap:addPart(source, partId)
local source = source or "self"
local partdata = {}
-- On recupère les données de chunks
-- Si le nom est "self", cela veut dire que fichier est le même que celui ou
-- se trouve le layout, qui est forcément le fichier du niveau. Cela veut dire
-- qu'il faut utiliser les parties de niveau du niveau actuel, localisée dans
-- self.controller.parts
if (source == "self") or (source == "") then
partdata = self.datas.parts
else
-- Si c'est un autre nom, on charge dans "partdata" la liste des partie de niveau
-- du fichier qu'on réfère.
local chunkfile = require("datas.gamedata.maps.shoot.chunks." .. source)
partdata = chunkfile.parts
end
local chunklist = partdata[partId]
-- chunklist fonctionne de la même manière que partlist.
-- chaque entrée dans la liste (chunkContainer) contient deux partie :
-- chunkContainer[1]: l'identifiant du fichier où se trouve le chunk voulu
-- chunkContainer[2]: la liste de chunks voulu. chaque entrée dedans est
-- un nombre correspondant à un chunk
for i, chunkContainer in ipairs(chunklist) do
for j, chunk in ipairs(chunkContainer[2]) do
self:addChunk(source, chunkContainer[1], chunk)
end
end
end
function ShootMap:addChunk(source, filename, chunkid)
local filename = filename or "self"
if (filename == "self") or (filename == "") then
filename = source
end
local chunkfile = require("datas.gamedata.maps.shoot.chunks." .. filename)
local chunkdata = chunkfile.chunks
local chunkpos = #self.layout
local chunkname = filename .. chunkid
if self.chunklist[chunkname] == nil then
self.chunklist[chunkname] = Chunk(self, chunkdata[chunkid])
end
table.insert(self.layout, chunkname)
self:updateWidth()
end
function ShootMap:getChunk(id)
return self.chunklist[self.layout[id]]
end
function ShootMap:addBlock(x, y, w, h, top, bottom)
@ -36,14 +149,25 @@ function ShootMap:loadActors()
-- Empty Placeholder function
end
function ShootMap:draw()
for i=1, 10 do
--love.graphics.draw(self.texture.floor, ((i-1)*31*16), 0)
end
function ShootMap:draw(x, y, w, h)
self:drawChunks(x)
end
function ShootMap:drawParallax(x, y, w, h)
self.parallaxBackground:drawParallax(x, y, w, h)
end
function ShootMap:drawChunks(x)
local x = x or 0
local firstChunk = math.floor(x / (8*31)) - 2
for i=1, 6 do
local chunkID = firstChunk + i
local chunk = self:getChunk(chunkID)
if (chunk ~= nil) then
chunk:draw((chunkID-1) * (8*31))
end
end
end
return ShootMap

View file

@ -0,0 +1,133 @@
local Chunk = Object:extend()
local ChunkTerrain = require "game.modules.world.maps.tools.chunkterrain"
function Chunk:new(map, data)
self.map = map
self.data = data
self.grounds = {}
self.areGroundsPrepared = false
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
function Chunk:spawnGrounds(x)
if (self.areGroundsPrepared == false) then
self:prepareGround()
end
self:generateGround(x)
end
function Chunk:prepareGround()
for i=1, 5 do
for j=1, 8 do
if (self.data.terrain[i][j] ~= 3) and (self:haveNoGround(j, i)) then
self:calculateGround(j, i)
--self.map.world:newCollision("floor", x+(j-1)*31, (i-1)*20, -48, 31, 20, 48)
end
end
end
self.areGroundsPrepared = true
end
function Chunk:generateGround(basex)
for i, ground in ipairs(self.grounds) do
local x, y = ground.x, ground.y
local w, h = ground.w, ground.h
self.map.world:newCollision("invisible", basex+(x-1)*31, (y-1)*20, -48, 31*w, 20*h, 48)
end
end
function Chunk:haveNoGround(x, y)
for i, ground in ipairs(self.grounds) do
if ground:isInside(x, y) then
return false
end
end
return true
end
function Chunk:addGround(x, y, w, h)
table.insert(self.grounds,ChunkTerrain(x, y, w, h))
end
function Chunk:calculateGround(x, y)
local groundHeight = 1
local groundWidth = 1
local maxHeight = 5-y
local maxWidth = 8-x
-- Creation de la première ligne
local lineEmpty = true
for i=0, maxWidth do
if self:testTerrain(x + i, y) and (lineEmpty) then
groundWidth = i + 1
else
lineEmpty = false
end
end
-- Pour optimiser, on commence à la seconde ligne cette boucle
for i=1, maxHeight do
lineEmpty = true
for j=0, (groundWidth-1) do
if self:testTerrain(x + j, y + i) == false then
lineEmpty = false
end
end
if (lineEmpty) then
groundHeight = i + 1
else
break
end
end
self:addGround(x, y, groundWidth, groundHeight)
end
function Chunk:testTerrain(x, y)
return (self.data.terrain[y][x] ~= 3) and (self:haveNoGround(x, y))
end
function Chunk:spawnObjects(x)
for i=1, 5 do
for j=1, 8 do
local id = self.data.objects[i][j]
if (id ~= 0) then
self.map.world:newObjFromIndex(id, x+(j-1)*31+12, (i-1)*20, 0)
end
end
end
end
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

View file

@ -0,0 +1,14 @@
local ChunkTerrain = Object:extend()
function ChunkTerrain:new(x, y, w, h)
self.x = x
self.y = y
self.w = w
self.h = h
end
function ChunkTerrain:isInside(x, y)
return ((x >= self.x) and (x < self.x+self.w) and (y >= self.y) and (y < self.y+self.h))
end
return ChunkTerrain

View file

@ -1,34 +1,32 @@
local World3D = require "core.modules.world.world3D"
local RadianceWorld = World3D:extend()
local ParentWorld = World3D:extend()
local customMap = require "game.modules.world.maps"
function RadianceWorld:new(scene, maptype, mapname)
local mappath = game.utils.getMapPath(maptype, mapname)
RadianceWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
function ParentWorld:new(scene, maptype, mapname)
local mappath = game.utils.getMapPath("test", "test")
self.customMap = customMap
ParentWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
self.mapname = mapname
self.autorun = false
end
function RadianceWorld:createMapController()
if (self.maptype == "test") then
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
function ParentWorld:createMapController()
customMap.Test(self)
end
function RadianceWorld:loadMapObjects()
RadianceWorld.super.loadMapObjects(self)
function ParentWorld:loadMapObjects()
ParentWorld.super.loadMapObjects(self)
self:addInvisibleWalls()
end
function RadianceWorld:addInvisibleWalls()
function ParentWorld:newObjFromIndex(id, x, y, z)
self.obj.index[id](self, x, y, z)
end
function ParentWorld:addInvisibleWalls()
local w, h = self:getDimensions()
print(w, h)
self.obj.collisions["invisible"](self, 0, -16, 0, w, 16, 1000)
@ -37,7 +35,11 @@ function RadianceWorld:addInvisibleWalls()
self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000)
end
function RadianceWorld:draw(dt)
function ParentWorld:getViewCenter(x, y)
return x, y-16
end
function ParentWorld:draw(dt)
self:drawBackgroundColor()
local camNumber = self.cameras:getViewNumber()
@ -55,11 +57,18 @@ function RadianceWorld:draw(dt)
end
end
function RadianceWorld:drawParallax(i)
function ParentWorld:drawMap(i)
local x, y, w, h = self.cameras:getViewCoordinate(i)
if (self.map ~= nil) then
self.map:draw(x, y, w, h)
end
end
function ParentWorld:drawParallax(i)
local x, y, w, h = self.cameras:getViewCoordinate(i)
if (self.map ~= nil) and (self.maptype ~= "sti") then
self.map:drawParallax(x, y, w, h)
end
end
return RadianceWorld
return ParentWorld

View file

@ -0,0 +1,23 @@
local ParentWorld = require "game.modules.world.parent"
local ShootWorld = ParentWorld:extend()
local customMap = require "game.modules.world.maps"
function ShootWorld:new(scene, mapname)
local mappath = game.utils.getMapPath("shoot", mapname)
ShootWorld.super.new(self, scene, "shoot", mapname)
self.mapname = mapname
self.autorun = true
end
function ShootWorld:getViewCenter(x, y)
return x+128, y-16
end
function ShootWorld:createMapController()
self.customMap.Shoot(self, self.maptype, self.mapname)
self.cameras:lockY(10)
end
return ShootWorld

View file

@ -1,16 +0,0 @@
return {
["textures"] = {
{"shadow", "assets/sprites/shadow.png"}
},
["sprites"] = {
{"ring", "assets/sprites/items/ring"}
},
["imagefonts"] = {
--{"medium", "assets/fonts/medium"}
},
["sfx"] = {
--{"navigate", "assets/sfx/menu_move.mp3"},
--{"confirm", "assets/sfx/menu_confirm.mp3"},
--{"cancel", "assets/sfx/menu_error.mp3"},
}
}

View file

@ -21,23 +21,22 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
local Scene = require "core.modules.scenes"
local MovePlayer = Scene:extend()
local PlayStyle = require "game.modules.subgames"
local MovePlayer = PlayStyle:extend()
local World = require "game.modules.world"
local TestWorld = require "game.modules.world.parent"
local ShootWorld = require "game.modules.world.shoot"
local BattleWorld = require "game.modules.world.battle"
function MovePlayer:new(map)
self.map = map
MovePlayer.super.new(self, {"shoot", "test", "battle"}, "testmissions", {"sonic"})
end
MovePlayer.super.new(self)
self.assets:batchImport("game.modules.gui.assets")
self.assets:batchImport("scenes.subgames.testBattle.assets")
World(self, "battle", map)
self.world:setPlayerNumber(1)
self.world.cameras:setMode("split")
self.world:loadMap()
function MovePlayer:initWorld()
--ShootWorld(self, "testlevel.test1")
BattleWorld(self, self.map)
--TestWorld(self)
end
return MovePlayer

View file

@ -1,16 +0,0 @@
return {
["textures"] = {
{"shadow", "assets/sprites/shadow.png"}
},
["sprites"] = {
{"ring", "assets/sprites/items/ring"}
},
["imagefonts"] = {
--{"medium", "assets/fonts/medium"}
},
["sfx"] = {
--{"navigate", "assets/sfx/menu_move.mp3"},
--{"confirm", "assets/sfx/menu_confirm.mp3"},
--{"cancel", "assets/sfx/menu_error.mp3"},
}
}

View file

@ -21,25 +21,22 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
local Scene = require "core.modules.scenes"
local MovePlayer = Scene:extend()
local PlayStyle = require "game.modules.subgames"
local MovePlayer = PlayStyle:extend()
local World = require "game.modules.world"
local TestWorld = require "game.modules.world.parent"
local ShootWorld = require "game.modules.world.shoot"
local BattleWorld = require "game.modules.world.battle"
function MovePlayer:new(playerNumber, cameraMode)
local playerNumber = playerNumber or 1
local cameraMode = cameraMode or "split"
function MovePlayer:new(map)
self.map = map
MovePlayer.super.new(self, {"shoot", "test", "battle"}, "testmissions", {"sonic"})
end
MovePlayer.super.new(self)
self.assets:batchImport("game.modules.gui.assets")
self.assets:batchImport("scenes.subgames.testShoot.assets")
World(self, "shoot", "forest")
self.world:setPlayerNumber(playerNumber)
self.world.cameras:setMode(cameraMode)
self.world:loadMap()
function MovePlayer:initWorld()
ShootWorld(self, "testlevel.test1")
--BattleWorld(self, self.map)
--TestWorld(self)
end
return MovePlayer