Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:09 26 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Direction Movement Keycheck

Author Message
jeff510
Newbie

Joined: 19/07/2020
Location: United States
Posts: 13
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
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024