The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading keyboard/joystick input
#2
Couple of ideas.

If your main loop is fairly short, you could have it call a keyscan routing and update a global variable as to what it found - and then reference this variable each time, rather than scanning each time.

If it's not short, or doesn't do scanning often enough, then you could do what sinclair did - have an interrupt routing that scans the keyboard 50 times a second and updates a variable with the result.

If you are running with standard ROM and interrupts on, you can of course always read the last keypress from the system variables. I did that with Berksman, so the last direction you chose is the one you move when you get to the corner. Even if you don't get there for a couple of seconds - press up, and let go of the keys, and you'll still turn upwards. Lastkey is a system variable described in the sinclair manual.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)