diff --git a/sonic-radiance.love/core/modules/scenes.lua b/sonic-radiance.love/core/modules/scenes.lua index 60f378c..5e5da95 100644 --- a/sonic-radiance.love/core/modules/scenes.lua +++ b/sonic-radiance.love/core/modules/scenes.lua @@ -36,6 +36,9 @@ function Scene:new() self.menusystem = MenuSystem() self.keys = core.input:getKeyList() + self.inputLocked = false + self.inputLockedTimer = 0 + self:register() end @@ -63,9 +66,33 @@ function Scene:clear() end +function Scene:setKeys() + if (self.inputLocked) then + self.keys = core.input.fakekeys + self.inputLockedTimer = self.inputLockedTimer - 1 + if (self.inputLockedTimer <= 0 ) then + self.inputLockedTimer = false + end + else + self.keys = core.input.keys + end + + self.menusystem.keys = self.keys +end + +function Scene:getKeys() + if (self.inputLocked) then + return self.keys + else + return core.input.fakekeys + end +end + function Scene:flushKeys() core.input:flushKeys() self.keys = core.input.keys + self.inputLockedTimer = 1 + self.inputLocked = true end return Scene diff --git a/sonic-radiance.love/core/modules/world/actors/actor2D.lua b/sonic-radiance.love/core/modules/world/actors/actor2D.lua new file mode 100644 index 0000000..2cc8002 --- /dev/null +++ b/sonic-radiance.love/core/modules/world/actors/actor2D.lua @@ -0,0 +1,24 @@ +local Actor2D = Object:extend() + +function Actor2D:new(world, type, x, h, w, h) + self.world = world + self.x = x or 0 + self.y = y or 0 + self.w = w or 0 + self.h = h or 0 + self.type = type or "" +end + +function Actor2D:register() + self.world:registerActor(self) +end + +function Actor2D:update(dt) + -- here will be update actions +end + +function Actor2D:draw() + -- here will be update actions +end + +return Actor2D diff --git a/sonic-radiance.love/core/modules/world/baseworld.lua b/sonic-radiance.love/core/modules/world/baseworld.lua new file mode 100644 index 0000000..fb02132 --- /dev/null +++ b/sonic-radiance.love/core/modules/world/baseworld.lua @@ -0,0 +1,25 @@ +local BaseWorld = Object:extend() + +function BaseWorld:new(scene) + self.scene = scene + + self.entities = {} +end + +function BaseWorld:registerEntity(entity) + table.insert(self.entities, entity) +end + +function BaseWorld:update(dt) + for i,v in ipairs(self.entities) do + v:update(dt) + end +end + +function BaseWorld:draw(dt) + for i,v in ipairs(self.entities) do + v:draw(dt) + end +end + +return BaseWorld diff --git a/sonic-radiance.love/core/scenemanager.lua b/sonic-radiance.love/core/scenemanager.lua index 008d0a2..dd24e66 100644 --- a/sonic-radiance.love/core/scenemanager.lua +++ b/sonic-radiance.love/core/scenemanager.lua @@ -54,9 +54,7 @@ end function SceneManager:update(dt) if (self.currentScene ~= nil) then - local keys = self.controller.input.keys - self.currentScene.keys = keys - self.currentScene.menusystem.keys = keys + self.currentScene:setKeys() self.currentScene.assets:update(dt) self.currentScene.menusystem:update(dt) self.currentScene:update(dt)