Batch problems with video games

I am making another batch video game that looks like a maze, and I have my controls set up, but I was wondering if there is a way to turn on a “collision” event in the script so that instead of outlining all the possible positions where the character might be in the game, I could just make it so that if there was nothing in front of the character, I would move forward, but if something was in front of him, I would replay this frame (stay in the same position). There is a link to my current game script at the bottom of this post. Say, if I had a simplified map that looked something like this:

@echo off
title level 1
cls
:MAIN
echo °°°°°°°ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»°°°°°°°°°°°°°°
echo °°°°°°°º       º       º X º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º Û º       º       º°°°°°°°°°°°°°°
echo °°°°°°°ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ°°°°°°°°°°°°°°
goto MAIN

My current control will be:

choice /c awsd /n 
IF %errorlevel%==2 goto a2
IF %errorlevel%==1 goto a1
IF %errorlevel%==4 goto a1
IF %errorlevel%==3 goto a1
goto a1

, ( ) , . ( , ), , - :

@echo off
title level 1
cls
:MAIN
echo °°°°°°°ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»°°°°°°°°°°°°°°
echo °°°°°°°º   Û   º       º X º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º       º       º°°°°°°°°°°°°°°
echo °°°°°°°ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ°°°°°°°°°°°°°°

:a1
choice /c awsd /n 
IF %errorlevel%==2 goto a2check
IF %errorlevel%==1 goto a3
IF %errorlevel%==4 goto a3
IF %errorlevel%==3 goto a3
goto a1


:a2check
set /p collision=<collision_check.bat
IF %collision%==yes goto collision_confirm
IF %collision%==no goto a2
goto MAIN

:collision_confirm
cls
goto MAIN


:a3
cls
:: somehow edit the map so that the character "Û" moves to the position 
:: specified by the user in the choice command section.

:: so the new position would be: 

echo °°°°°°°ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»°°°°°°°°°°°°°°
echo °°°°°°°º     Û º       º X º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º   º   º   º   º°°°°°°°°°°°°°°
echo °°°°°°°º   º       º       º°°°°°°°°°°°°°°
echo °°°°°°°ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ°°°°°°°°°°°°°°


goto a3

collision_check.bat, , , , . , , !

+3
2

.

.

/.
- x, y .
.
"" , .

@echo off
setlocal EnableDelayedExpansion
set line[0]=#####
set line[1]=# # #
set line[2]=# # #
set line[3]=# # #
set line[4]=#   #
set line[5]=#####
set pos.x=3
set pos.y=1

:game
call :display
call :Move
goto :game

:display
cls
set /a xAdd1=pos.x+1
for /L %%n in (0,1,5) do (
    set line=!line[%%n]!
    if %%n==%pos.y% (
        set line=!line:~0,%pos.x%!X!line:~%xAdd1%!
    )
    echo !line!
)
goto :eof
+1

:

BatBox - , , . , .

, BatBox , .

http://dos9.org/doc/en/html/batbox.html

-1

Source: https://habr.com/ru/post/1778408/


All Articles