kbmonkey wrote:
I don't know if feels right that the turret monopolized the mouse. If other people wanted to use the mouse it makes it difficult for them. I was thinking of changing it so you need to click on the turret first to use it, and release it with right-click perhaps. I am not sure, just throwing ideas around.
Thats a good point, handling the input is quite difficult in such an open project. Technically the base code will procceed all inputs, even if a key or button is used serveral times.
There are also some default keys / buttons / axis that will most likely be used a couple times, e.g:
- Arrow Keys (e.g for movement or interface actions like selecting buttons in menus, ...)
- WASD
- Space / Return ; ...
- Mouse Buttons / Position
- Controller Buttons / Axis
- ...
One idea would be good communication and organisation.
Also maybe a new module that somehow can be used to manage inputs can be introduced and people use that module (if they want) to set keys and buttons for their own module if a specific state has been set.
Some pseudo code:
Code: Select all
-------------------------------
-- A player char module --
-------------------------------
function module:enter()
-- Load the input module --
self.inputModule = Game:getModule("InputModule")
-- if the state "gameActive" get set, module:setInput() will be triggered.
self.inputModule:addState("gameActive", self)
end
function module:setInput()
-- the table key is the input ; the table value is a function to call if the input is down.
-- On hold calls --
self.holdInput = {"w" = entity.moveUp, "s" = entity.moveDown}
self.inputModule:onHold(self.holdInput)
-- On press calls --
self.pressInput = {" " = entity.jump, "r" = entity.reload}
self.inputModule:onPressed(self.pressInput)
end
Other modules can listen to the "gameState" state too and set their own keys and buttons if "gameState" is selected. And if any input is used by more then one module then the inputModule will show a warning or/and block one of them based on a specifc condition that has been set previously. That way it would be easy to seperate stuff like "player movement" and "interface interactions" (like an ingame menu with buttons etc.).
But all that stuff will make the module more and more complex (and I want it to be really easy for new contributors to join). Maybe we should accept the risk that some keys get set several times and if so we talk with the author who made the conflicting module and maybe these guys can find a way to solve it.
btw I've updated the OP , Github Readme and the WIki and cleaned up some code.