[SOLVED]And yet, another padawan asking for help: multiple-input issue.
Posted: Tue Apr 11, 2017 10:06 pm
Hello, fellow Lövers! Whilst I’m here requesting some help, I want to thank in advance for anyone who might try to aid me in this small issue I’m having--even if you don’t, necessarily, solve my problem.
Well, moving straightly to the point, I have a small project with the following conditions in mind:
* The game must have the love.physics module
* The number of players is not constant, I’ve temporarily mapped some keys (f1, f2) to change the amount of players and others (WASD/Arrows) to move them --for now, only 2 players are movable.
* Players must be able to move freely through the canvas.
Here begins my problem: If only one player is on the screen, GREAT! It is possible to move as you wish, but when a second player gets into action. . . things get messy. Players can’t just input commands simultaneously, if someone moves diagonally to any direction chances are high that the other player (usually the second) is not going to be able to move at all. In addition, I believe this next issue is related to my poorly implemented deceleration algorithm, if only the second player is moving and he collides with the first player, it is possible that the second player becomes unable to input any new action (unless he releases all his keys). The latter issue I can try to solve on my own, as it doesn’t always happen and I didn't describe it in a fashionable way for you guys to really understand, nonetheless all help is appreciated.
All that I can add for now is some irrelevant (or relevant?) information such as: I’m new to programming, generally speaking, that is the first project I aim to complete in terms of computer languages, besides the html/css/Jscript stuff I do once in a while, and though I’ve born in the same country Lua was created, I’m more familiar with Python, thus part of my stupidities can be related to that, I’m still catching Lua. I'm not going to post the code here, but rather upload the game.love file, as it would make this post a really big post.
Well, moving straightly to the point, I have a small project with the following conditions in mind:
* The game must have the love.physics module
* The number of players is not constant, I’ve temporarily mapped some keys (f1, f2) to change the amount of players and others (WASD/Arrows) to move them --for now, only 2 players are movable.
* Players must be able to move freely through the canvas.
Here begins my problem: If only one player is on the screen, GREAT! It is possible to move as you wish, but when a second player gets into action. . . things get messy. Players can’t just input commands simultaneously, if someone moves diagonally to any direction chances are high that the other player (usually the second) is not going to be able to move at all. In addition, I believe this next issue is related to my poorly implemented deceleration algorithm, if only the second player is moving and he collides with the first player, it is possible that the second player becomes unable to input any new action (unless he releases all his keys). The latter issue I can try to solve on my own, as it doesn’t always happen and I didn't describe it in a fashionable way for you guys to really understand, nonetheless all help is appreciated.
All that I can add for now is some irrelevant (or relevant?) information such as: I’m new to programming, generally speaking, that is the first project I aim to complete in terms of computer languages, besides the html/css/Jscript stuff I do once in a while, and though I’ve born in the same country Lua was created, I’m more familiar with Python, thus part of my stupidities can be related to that, I’m still catching Lua. I'm not going to post the code here, but rather upload the game.love file, as it would make this post a really big post.