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,
tilewidth = 16,
tileheight = 16,
nextlayerid = 6,
nextobjectid = 17,
nextlayerid = 7,
nextobjectid = 19,
properties = {},
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
}
},
{
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",
draworder = "topdown",

View file

@ -1,5 +1,5 @@
<?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>
<export target="test2.lua" format="lua"/>
</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
</data>
</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">
<object id="4" x="240" 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.ItemBox = require(cwd .. "itembox")
Obj.RingBox = require(cwd .. "ringbox")
Obj.Encounter = require(cwd .. "encounter")
Obj.index = {}
Obj.index["player"] = Obj.Player
@ -14,6 +15,7 @@ Obj.index["gizmo"] = Obj.Gizmo
Obj.index["ring"] = Obj.Ring
Obj.index["itembox"] = Obj.ItemBox
Obj.index["ringbox"] = Obj.RingBox
Obj.index["encounter"] = Obj.Encounter
Obj.collisions = {}
Obj.collisions["wall"] = require(cwd .. "wall")

View file

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

View file

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

View file

@ -16,4 +16,12 @@ function RPGWorld:createMapController()
RPGMap(self, self.folder, self.area)
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