core: use newest version

This commit is contained in:
Kazhnuz 2019-04-01 08:25:51 +02:00
parent cf38b3c326
commit d2588cba74
4 changed files with 77 additions and 3 deletions

View file

@ -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:flushKeys()
core.input:flushKeys()
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

View file

@ -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

View file

@ -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

View file

@ -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)