feat(overworld): add transition to the cbs

This commit is contained in:
Kazhnuz 2021-04-02 22:46:37 +02:00
parent 0cd282027c
commit 001ae44eec
7 changed files with 102 additions and 5 deletions

View file

@ -8,8 +8,8 @@ return {
height = 40, height = 40,
tilewidth = 16, tilewidth = 16,
tileheight = 16, tileheight = 16,
nextlayerid = 6, nextlayerid = 7,
nextobjectid = 17, nextobjectid = 19,
properties = {}, properties = {},
tilesets = { tilesets = {
{ {
@ -442,6 +442,45 @@ return {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
} }
}, },
{
type = "objectgroup",
draworder = "topdown",
id = 6,
name = "encounter",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
objects = {
{
id = 17,
name = "",
type = "",
shape = "rectangle",
x = 192,
y = 240,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 18,
name = "",
type = "",
shape = "rectangle",
x = 336,
y = 240,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
}
}
},
{ {
type = "objectgroup", type = "objectgroup",
draworder = "topdown", draworder = "topdown",

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="30" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="17"> <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="30" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="7" nextobjectid="20">
<editorsettings> <editorsettings>
<export target="test2.lua" format="lua"/> <export target="test2.lua" format="lua"/>
</editorsettings> </editorsettings>
@ -92,6 +92,10 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data> </data>
</layer> </layer>
<objectgroup id="6" name="encounter">
<object id="17" x="192" y="240" width="16" height="16"/>
<object id="18" x="336" y="240" width="16" height="16"/>
</objectgroup>
<objectgroup id="2" name="ring"> <objectgroup id="2" name="ring">
<object id="4" x="240" y="96" width="16" height="16"/> <object id="4" x="240" y="96" width="16" height="16"/>
<object id="5" x="288" y="96" width="16" height="16"/> <object id="5" x="288" y="96" width="16" height="16"/>

View file

@ -0,0 +1,36 @@
local cwd = (...):gsub('%.encounter$', '') .. "."
local Gizmo = require(cwd .. "gizmo")
local Encounter = Gizmo:extend()
local overrides = {
["isSolid"] = false,
["charset"] = "item1",
["charId"] = 2,
["destroy"] = "none",
["needButton"] = false,
["isTurning"] = true,
}
function Encounter:new(world, x, y)
Encounter.super.new(self, world, x, y, 16, 16, overrides)
end
function Encounter:action()
core.scenemanager:storeCurrentScene("afterBattle")
local ox, oy = self.world.cameras:getViewCoordinate(1)
game.cbs:startBattle("test", "testBattle", self.x - ox, self.y - oy)
self.world.encounter = self
end
function Encounter:drawCharset(charset, charId)
local x, y = utils.math.floorCoord(self.x, self.y)
y = y - 2
love.graphics.setColor(1,1,1,0.5)
self.assets.images["shadow"]:draw(x, y + 11)
utils.graphics.resetColor()
self.assets.sprites["encounter"]:drawAnimation(x - 1, y + 10)
end
return Encounter

View file

@ -7,6 +7,7 @@ Obj.Gizmo = require(cwd .. "gizmo")
Obj.Ring = require(cwd .. "ring") Obj.Ring = require(cwd .. "ring")
Obj.ItemBox = require(cwd .. "itembox") Obj.ItemBox = require(cwd .. "itembox")
Obj.RingBox = require(cwd .. "ringbox") Obj.RingBox = require(cwd .. "ringbox")
Obj.Encounter = require(cwd .. "encounter")
Obj.index = {} Obj.index = {}
Obj.index["player"] = Obj.Player Obj.index["player"] = Obj.Player
@ -14,6 +15,7 @@ Obj.index["gizmo"] = Obj.Gizmo
Obj.index["ring"] = Obj.Ring Obj.index["ring"] = Obj.Ring
Obj.index["itembox"] = Obj.ItemBox Obj.index["itembox"] = Obj.ItemBox
Obj.index["ringbox"] = Obj.RingBox Obj.index["ringbox"] = Obj.RingBox
Obj.index["encounter"] = Obj.Encounter
Obj.collisions = {} Obj.collisions = {}
Obj.collisions["wall"] = require(cwd .. "wall") Obj.collisions["wall"] = require(cwd .. "wall")

View file

@ -8,6 +8,7 @@ return {
["sprites"] = { ["sprites"] = {
{"cursorground", "assets/gui/cursor/ground"}, {"cursorground", "assets/gui/cursor/ground"},
{"hitGFX", "assets/sprites/gfx/hit"}, {"hitGFX", "assets/sprites/gfx/hit"},
{"encounter", "assets/sprites/encounter"},
}, },
["textures"] = { ["textures"] = {
{"menucursor", "assets/gui/cursor-menulist.png"}, {"menucursor", "assets/gui/cursor-menulist.png"},

View file

@ -67,11 +67,14 @@ function OverWorld:new()
end end
function OverWorld:updateCurrentMap(map) function OverWorld:updateCurrentMap(map)
self.assets:setMusic("assets/music/" .. map.music .. ".mp3") self:playMapMusic(map)
self.assets:playMusic()
self:showMessage(map.name) self:showMessage(map.name)
end
function OverWorld:playMapMusic(map)
self.assets:setMusic("assets/music/" .. map.music .. ".mp3")
self.assets:playMusic()
end end
function OverWorld:startEvent() function OverWorld:startEvent()
@ -131,6 +134,10 @@ function OverWorld:pause()
screens.mainmenu.pause(self) screens.mainmenu.pause(self)
end end
function OverWorld:restored()
self.world:restoreActions()
end
function OverWorld:timerResponse(timer) function OverWorld:timerResponse(timer)
if (timer == "unPause") then if (timer == "unPause") then
self.isPaused = false self.isPaused = false

View file

@ -16,4 +16,12 @@ function RPGWorld:createMapController()
RPGMap(self, self.folder, self.area) RPGMap(self, self.folder, self.area)
end end
function RPGWorld:restoreActions()
self.encounter:destroy()
local currentMap = self.map:getMapAtPoint(self.players[1].actor.x, self.players[1].actor.y)
self.players[1].actor.xsp = 0
self.players[1].actor.ysp = 0
self.scene:playMapMusic(currentMap)
end
return RPGWorld return RPGWorld