-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key Repeat Delay and Release for P5js? #56
Comments
Hi, sorry, I completely missed this ticket, seems like I didn't get an eMail for it :( The long answer first: When DOjS is running it calls
The
This object is assembled by querying the current Allegro state:
So p5js has the Line 120 in b1d60fc
In short: I have two suggestions:
|
Thank you for your comprehensive response! Here's a simple p5js editor script: https://editor.p5js.org/mikkos.koiranen/sketches/HlYKJ3-5v that shows the result I'm after: when holding down arrow keys, the yellow pixel immediately moves as it should do in a game. Also, two arrow keys can be pressed simultaneously, and the pixel moves diagonally. Here's the same thing executed with a DOjS script, in which when the keys are held down, the movement is done like typing text: first one "step" is taken, then pause, then there are multiple steps as long as the key is held down; that's not an ideal way to move in a game. :) I maybe could avoid this with some coding, but that would need a way to detect the key release. And, it's not possible to press two letters at the same time and move the pixel diagonally. |
Right, now I'm getting what you are aiming at. I tested some stuff and (right now), there is really no way of doing that with DOjS. Neither the native API, nor the p5js emulation are able to provide the info of multiple keypresses. However: the functionality is available in Allegro: https://liballeg.org/stabledocs/en/alleg006.html#key I will make this array available in the Javascript world with the next release. My Idea would be to provide an array with boolean values and you can take the KEY-definitions from func.js to check if a given key is currently down. I can't really make promises on when I'll manage to try that, but I can give you a test version as soon as I have one if you are interested... |
Update: this was actually easier than I thought. Please try this unofficial v1.13 |
Hello and thank you very much for your effort! With the script "keytest.js" the unofficial patch works exactly as it should: the keys can be held down now and they even can be pressed simultaneously allowing diagonal movement. I'm waiting for the official release, but take your time; at the moment I'm also investigating C programming with the Allegro library and DJGPP for developing DOS games. :) |
I'll try to make smaller, but more frequent DOjS releases in the future. V1.10 and v1.11 took way too long. Feel free to contact me on Mastodon or in Discord (see DOjS README.md) if you have questions regarding DJGPP and/or Allegro. |
Hello!
I'm interested in developing a p5js game for DOS using this awesome system you have created. :)
However, at the moment there are two problems:
The text was updated successfully, but these errors were encountered: