diff --git a/gamecore/callbacks.lua b/gamecore/callbacks.lua index 9ff576d..39fe422 100644 --- a/gamecore/callbacks.lua +++ b/gamecore/callbacks.lua @@ -36,3 +36,11 @@ end function love.mousepressed( x, y, button, istouch ) core:mousepressed(x, y, button, istouch) end + +function love.keypressed( key, scancode, isrepeat ) + core:keypressed( key, scancode, isrepeat ) +end + +function love.keyreleased(key) + core:keyreleased( key ) +end diff --git a/gamecore/init.lua b/gamecore/init.lua index f0eeb40..1831d01 100644 --- a/gamecore/init.lua +++ b/gamecore/init.lua @@ -57,7 +57,7 @@ function CoreSystem:new() end -- MOUSE FUNCTIONS --- Initialize and configure the core object +-- get directly the mouse when needed function CoreSystem:mousemoved(x, y, dx, dy) local x, y = self.screen:project(x, y) @@ -70,6 +70,17 @@ function CoreSystem:mousepressed( x, y, button, istouch ) self.scenemanager:mousepressed( x, y, button, istouch ) end +-- KEYBOARD FUNCTIONS +-- get directly the keyboard when needed + +function CoreSystem:keypressed( key, scancode, isrepeat ) + self.scenemanager:keypressed( key, scancode, isrepeat ) +end + +function CoreSystem:keyreleased( key ) + self.scenemanager:keyreleased( key ) +end + -- UPDATE FUNCTIONS -- Load every sytem every update functions of the scene and objects diff --git a/gamecore/modules/scenes.lua b/gamecore/modules/scenes.lua index d60f442..eeb616d 100644 --- a/gamecore/modules/scenes.lua +++ b/gamecore/modules/scenes.lua @@ -72,6 +72,17 @@ function Scene:mousepressed( x, y, button, istouch ) -- Empty function, is just here to avoid crash end +-- KEYBOARD FUNCTIONS +-- Add send keys functions to the scene + +function SceneManager:keypressed( key, scancode, isrepeat ) + +end + +function SceneManager:keyreleased( key ) + +end + -- DRAW FUNCTIONS -- Draw the scene and its content @@ -79,7 +90,7 @@ function Scene:draw() end --- KEYBOARD FUNCTIONS +-- INPUT FUNCTIONS -- Handle inputs from keyboard/controllers function Scene:setKeys() diff --git a/gamecore/scenemanager.lua b/gamecore/scenemanager.lua index a1041c5..832d40c 100644 --- a/gamecore/scenemanager.lua +++ b/gamecore/scenemanager.lua @@ -90,6 +90,17 @@ function SceneManager:mousepressed( x, y, button, istouch ) end end +-- KEYBOARD FUNCTIONS +-- Add send keys functions to the scene + +function SceneManager:keypressed( key, scancode, isrepeat ) + self.currentScene:keypressed( key, scancode, isrepeat ) +end + +function SceneManager:keyreleased( key ) + self.currentScene:keyreleased( key ) +end + -- DRAW FUNCTIONS -- Draw the current scene