I made this game, MouseTrap, in the old b4gl in 2005 for Windows.
Now in 2018 adapted in Basic4GLmobile to run it on Android devices.
It's good to see some activity around here :-)
There's some game input routines that come bundled with Basic4GL Mobile that might be helpful. Particularly the standard\gameinput.inc file, which contains a routine for getting directional and button input. On PC it reads the arrow keys, but on Android it displays touch input controls. I used to to convert Peter's "Sokomouse" game, but unfortunately I haven't been able to contact him to get permission to release it.
Here's a simple example:
' Standard game input routines. ' These are included in the "Basic4GL Mobile" folder that the installer creates. ' If you save your program somewhere else, you will need to copy the "standard" folder into the same location, ' as well as the "gfx" folder, which contains the images it requires to display the UI on Android. ' The "gfx" folder must also be copied to the "basic4gl" folder on Android (along side program.vm) include standard\gameinput.inc
resizetext(40,30) settextscroll(false) cls dim x = 20, y = 15, xd = 0, yd = 0
' Configure the input we need uiGamepadDef.joystick.mode = JOYSTICK_4WAY ' Up/down/left/right only (no diagonals) uiGamepadDef.joystick.isAnalog = false ' On screen joystick snaps to full direction uiGamepadDef.joystick.deadzone# = 0.5 ' Half of circle is dead zone uiGamepadDef.buttonCount = 0 ' Don't need any buttons
' Game input will be stored here dim gamepad as TGamepadInput
' Main loop while true
' Update the screen. ' Because the input routines use the "immediate mode" GUI, we must use UIBegin() and UIEnd(). ' These routines automatically clear the screen and perform a DrawText() UIBegin()
' Get input. This must be done between UIBegin() and UIEnd(), as it needs to render ' to the screen (on Android anyway) gamepad = GetGamepadInput()
' Draw the X locate x, y: print "X"; UIEnd()
' Update game state. User input is stored in the gamepad variable. xd = gamepad.dir#(0) yd = gamepad.dir#(1) x = x + xd: y = y + yd if x < 0 then x = 0 endif if x > 39 then x = 39 endif if y < 0 then y = 0 endif if y > 29 then y = 29 endif