Posted: 03:51am 20 Jul 2020 |
Copy link to clipboard |
Print this post |
|
I'm just starting out with the CMM2, and I wanted a good keycheck method that doesn't rely on the typematic repeat. This allows for diagonal movement, for example, and can be expanded for two-player games using WASD as well.
Here's my solution:
do KEYCHECK print @(100,100) " UP:" u_pressed print @(100,200) " DOWN:" d_pressed print @(100,300) " LEFT:" l_pressed print @(100,400) "RIGHT:" r_pressed loop
SUB KEYCHECK for keycode = 128 to 131 pressed = 0 for key = 1 to 6 if keydown(key) = keycode then pressed = 1 next if keycode = 128 then u_pressed = pressed if keycode = 129 then d_pressed = pressed if keycode = 130 then l_pressed = pressed if keycode = 131 then r_pressed = pressed next END SUB
|