Multiple Input System

Previous topic - Next topic

MrTAToad

This is one of my routines in BallZ II Redux that you may find interesting.  The idea is that you can't really expect a PC user to have a mouse - for some reason the program could be running in a kiosk for example, and thus a mouse isn't available.

Therefore both system and/or sprite pointer needs to be controlled by other input systems - for desktop machines this would be :


  • Mouse
  • Keyboard
  • Joypad

For mobile devices it is limited to :


  • Screen press
  • Tilting the device

For both sets of lists you could of course add virtual joysticks, but I dont really like them as they take up too much space, especially on phones.  Plus, as my OSJ routine demonstrated they aren't simple to program.

Hence the multiple input system :  It is designed to receive input from mice/screen press, all available joypad/device tilt and the keyboard in one go, process the direction with the current movement speed value and the usual frame rate processing routine.

The result is that in the end you can get the mouse position or a value, no matter what device was used, for moving an object.  You can get the global "mouse" value which is updated by all devices, or a specific device value.

Keyboard controls are fixed to the cursor keys and Left Control, although that can easily be changed (or better yet, redefined by the user).

There are a few optimisations that can be implemented, but at the moment, it works very well.

[attachment deleted by admin]