Proximity Service uses your device's proximity sensor to control the screen on/off state. Simply covering the sensor will turn the screen off whilst keeping the device awake - perfect for games that need to be running in the foreground but don't need your continuous attention. Flip your phone on a table, place it in your pocket, or use any other means to cover the proximity sensor. As soon as the sensor is uncovered, the screen will come back on.
Note that Proximity Service does not prevent the device from falling asleep when the device is being used normally with the screen on and user activity timeout has been reached. However, the device will not fall asleep as long as the screen has been turned off by the proximity sensor as this effectively counts as continuous user activity.
Regarding incompatible devices - if your device is listed as incompatible with Proximity Service, turning the screen off on these devices enforces pausing of any foreground apps, so the usefulness of this app is significantly reduced. If your device has an AMOLED screen you may be able to find an alternative app that works for you if that app uses a black screen overlay to achieve the screen off effect.
This app is open source - follow the website link at the bottom of this Play Store listing for the GitHub repo.