Compare commits
7 commits
a315fcebb5
...
f3d175266b
Author | SHA1 | Date | |
---|---|---|---|
|
f3d175266b | ||
|
f9b936a726 | ||
|
3cb6c61cac | ||
|
eec43a522e | ||
|
f892b1ce4e | ||
|
de08fbd56b | ||
|
4722b734ed |
8 changed files with 122 additions and 18 deletions
|
@ -36,9 +36,11 @@ end
|
|||
|
||||
function DataManager:loadDatas()
|
||||
self.datapacks = {}
|
||||
for key, datas in pairs(index.datapacks) do
|
||||
self.core.debug:debug("datamanager", "loading data for " .. key)
|
||||
self.datapacks[key] = DataPack(datas[1], datas[2], datas[3], datas[4], datas[5])
|
||||
if (index.datapack ~= nil) then
|
||||
for key, datas in pairs(index.datapacks) do
|
||||
self.core.debug:debug("datamanager", "loading data for " .. key)
|
||||
self.datapacks[key] = DataPack(datas[1], datas[2], datas[3], datas[4], datas[5])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
102
birb/gamesystem/init.lua
Normal file
102
birb/gamesystem/init.lua
Normal file
|
@ -0,0 +1,102 @@
|
|||
-- GameSystem :: The main GameSystem subsystem. Basically a big object that handle all the
|
||||
-- GameSystem-related data like characters, monsters, etc. While the core aim to be
|
||||
-- reusable at will, the GameSystem is specifically made for the current GameSystem.
|
||||
|
||||
--[[
|
||||
Copyright © 2019 Kazhnuz
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
|
||||
|
||||
local Serializer = require "birb.classes.serializable.serializer"
|
||||
local GameSystem = Serializer:extend()
|
||||
|
||||
local VAR_TO_SERIALIZE = {
|
||||
"gametime",
|
||||
"destroyedGizmo",
|
||||
"variables",
|
||||
"flags"
|
||||
}
|
||||
|
||||
function GameSystem:new()
|
||||
self.slot = -1
|
||||
self.slotNumber = 3
|
||||
self.version = core.conf.gameversion or "N/A"
|
||||
self:reset()
|
||||
GameSystem.super.new(self, VAR_TO_SERIALIZE)
|
||||
end
|
||||
|
||||
function GameSystem:reset()
|
||||
self.gametime = 0
|
||||
|
||||
self.flags = {}
|
||||
self.destroyedGizmo = {}
|
||||
self.variables = {}
|
||||
self.mapName = ""
|
||||
end
|
||||
|
||||
function GameSystem:reload()
|
||||
self:read(self.slot)
|
||||
end
|
||||
|
||||
function GameSystem:read(save_id)
|
||||
self.slot = save_id
|
||||
if (self.slot > 0) then
|
||||
self:deserialize(self:getSaveName())
|
||||
end
|
||||
end
|
||||
|
||||
function GameSystem:deleteCurrentSave()
|
||||
if (self.slot > 0) then
|
||||
self:delete(self:getSaveName())
|
||||
self.metadata:remove(self.slot)
|
||||
end
|
||||
end
|
||||
|
||||
function GameSystem:write()
|
||||
if (self.slot > 0) then
|
||||
self:serialize(self:getSaveName())
|
||||
end
|
||||
end
|
||||
|
||||
function GameSystem:getSaveName(saveslot)
|
||||
local saveslot = saveslot or self.slot
|
||||
return "save" .. saveslot .. ".save"
|
||||
end
|
||||
|
||||
function GameSystem:resetSaves()
|
||||
for i=1, self.slotNumber do
|
||||
self:delete(self:getSaveName(i))
|
||||
end
|
||||
end
|
||||
|
||||
function GameSystem:update(dt)
|
||||
self.gametime = self.gametime + dt
|
||||
end
|
||||
|
||||
function GameSystem:getTime()
|
||||
return utils.time.getFields(self.gametime)
|
||||
end
|
||||
|
||||
function GameSystem:getTimeString()
|
||||
return utils.time.toString(self.gametime)
|
||||
end
|
||||
|
||||
function GameSystem:printTime()
|
||||
core.debug:print(self:getTimeString())
|
||||
end
|
||||
|
||||
return GameSystem
|
|
@ -66,7 +66,7 @@ function TextMenu:generateSubmenu(pageName, label, parent, list, func, backWidge
|
|||
end
|
||||
|
||||
function TextMenu:setFont(fontName)
|
||||
local scene = core.scenemanager.currentScene
|
||||
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
|
||||
self.font = scene.assets:getFont(fontName)
|
||||
end
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ function PhysicalActor:addHitboxFromFrameData(framedata, animationID, frameID, h
|
|||
if (hitbox.type == "main") then
|
||||
self.mainHitbox:setFromData(hitbox.box, sx, sy)
|
||||
else
|
||||
local hitboxName = anim .. frame .. type .. id
|
||||
local hitboxName = anim .. frame .. hitbox.type .. id
|
||||
self:addHitbox(hitboxName, hitbox.type, hitbox.box, sx, sy, hitbox.isSolid)
|
||||
return hitboxName
|
||||
end
|
||||
|
|
|
@ -5,8 +5,8 @@ local TiledMixins = Object:extend()
|
|||
|
||||
function TiledMixins:batchActor(objectlayer, object, layerx, layery)
|
||||
local name = objectlayer.name
|
||||
local gwidth = object.properties.gwidth or self.sti.tilewidth
|
||||
local gheight = object.properties.gheight or self.sti.tileheight
|
||||
local gwidth = object.properties.gwidth or self.wrapper.sti.tilewidth
|
||||
local gheight = object.properties.gheight or self.wrapper.sti.tileheight
|
||||
local x = object.x + layerx
|
||||
local y = object.y + layery
|
||||
local z = object.properties.z or 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local GameSystem = require "birb.modules.gamesystem"
|
||||
local GameSystem = require "birb.gamesystem"
|
||||
local Game = GameSystem:extend()
|
||||
|
||||
function Game:new()
|
||||
|
|
|
@ -40,7 +40,7 @@ function Player:updateStart(dt)
|
|||
end
|
||||
|
||||
if (self.isPunching) then
|
||||
self:checkHitboxesCollisions()
|
||||
self:applyHitboxesCollisions()
|
||||
end
|
||||
|
||||
if self.keys["start"].isPressed then
|
||||
|
@ -87,7 +87,7 @@ function Player:setDirection(direction)
|
|||
if direction ~= 0 then
|
||||
direction = utils.math.sign(direction)
|
||||
self.direction = direction
|
||||
self.sprite:setScalling(direction, nil)
|
||||
self.sprite:setScallingX(direction)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,24 +36,24 @@ function Plateformer:new()
|
|||
|
||||
World(self, folder .. ".actors", "datas/maps/plateformer/platformer.lua")
|
||||
|
||||
Pause(self)
|
||||
self.menusystem:deactivate()
|
||||
self.menusystem:lockWorldWhenActive(true)
|
||||
self.menusystem:lockAssetsWhenActive(true)
|
||||
--Pause(self)
|
||||
--self.menusystem:deactivate()
|
||||
--self.menusystem:lockWorldWhenActive(true)
|
||||
--self.menusystem:lockAssetsWhenActive(true)
|
||||
|
||||
self.world:loadMap()
|
||||
end
|
||||
|
||||
function Plateformer:restart()
|
||||
self.menusystem:deactivate()
|
||||
--self.menusystem:deactivate()
|
||||
collectgarbage()
|
||||
self.world:reset()
|
||||
end
|
||||
|
||||
function Plateformer:update(dt)
|
||||
if (self.menusystem.isActive == true) and self.sources[1].keys["start"].isPressed then
|
||||
self.menusystem:deactivate()
|
||||
end
|
||||
--if (self.menusystem.isActive == true) and self.sources[1].keys["start"].isPressed then
|
||||
--self.menusystem:deactivate()
|
||||
--end
|
||||
end
|
||||
|
||||
function Plateformer:draw()
|
||||
|
|
Loading…
Reference in a new issue