#1 16 May 2021 10:29

From: Cracow, Poland
Registered: 18 Mar 2021
Posts: 16

How to set a choice delay to less than a second

Hello, I am developing a batch game called SpaceRun, and I am using the choice command for keyboard handling, like this:

choice /c NMZQ /t 1 /d Z >nul
set key=%errorlevel%
if %key% equ 1 set /a position=position-1& set /a fuel=fuel-1
if %key% equ 2 set /a position=position+1& set /a fuel=fuel-1
if %key% equ 4 goto :menu

As you can see, N and M are moving the spaceship, 4 is used to back to the main menu, and, if the player do not press any key during a second, the Z key is virtually pressed, and the game continues without moving the spaceship. But, waiting whole second per frame is making the game too slow. Is it possible to set a choice delay to smaller value (but not to zero)?


#2 16 May 2021 11:07

Registered: 15 Oct 2020
Posts: 16

Re: How to set a choice delay to less than a second

The approach your taking is not supported by batch syntax, however, Dave Benham has developed a pure batch method of taking non blocking input for his snake.bat game.

Alternatively, Aacini's getKey.exe is a very easy to use external for taking input in a way that supports a high frame rate.

Last edited by T3RRY (16 May 2021 11:08)


Board footer

Powered by FluxBB