Ok, so I am working on a "game" written in batch and I came across a problem. I'm just showing a smaller example of the game to reduce confusion and unneeded coding. So, in a display that looks like:
#####
#O # #=All the walls
#
# # O=Movable Character
# # Spaces=Area to move
#####
I need to find a way to have the bold
# be a wall which will keep the character (O) to stay where is was at when you directed it towards it. It would look something like this:
##### If I made the "O" go right,
# # it would hold that position.
#O
# # I want the "O" to hold it's
# # position from the top,
##### bottom, and left of the
# as well.
That is the problem though, because I can only assign it to go to a single place if the "O" is going to the
#.
This is the example code which I am showing you:
Or just download it from
here.
@echo off
mode con cols=14 lines=7
title Test
color 0f
set position=7
call :layout
set a7=#
goto redir
:screen
cls
echo %a1%%a2%%a3%%a4%%a5%
echo %a6%%a7%%a8%%a9%%a10%
echo %a11%%a12%%a13%%a14%%a15%
echo %a16%%a17%%a18%%a19%%a20%
echo %a21%%a22%%a23%%a24%%a25%
goto :eof
:redir
call :screen
:prompt
choice /c wasde /n
if errorlevel 5 exit
if errorlevel 4 set /a position=%position%+1&goto ifcheck
if errorlevel 3 set /a position=%position%+5&goto ifcheck
if errorlevel 2 set /a position=%position%-1&goto ifcheck
if errorlevel 1 set /a position=%position%-5&goto ifcheck
:layout
set a1=Û
set a2=Û
set a3=Û
set a4=Û
set a5=Û
set a6=Û
set a7=±
set a8=±
set a9=±
set a10=Û
set a11=Û
set a12=±
set a13=Û
set a14=±
set a15=Û
set a16=Û
set a17=±
set a18=±
set a19=±
set a20=Û
set a21=Û
set a22=Û
set a23=Û
set a24=Û
set a25=Û
goto :eof
:ifcheck
if %position%==2 set position=7
if %position%==3 set position=8
if %position%==4 set position=9
if %position%==6 set position=7
if %position%==11 set position=12
if %position%==16 set position=17
if %position%==22 set position=17
if %position%==23 set position=18
if %position%==24 set position=19
if %position%==10 set position=9
if %position%==15 set position=14
if %position%==20 set position=19
call :layout
set a%position%=#
goto redir
If I was not clear enough, please tell me. I tried my best.
-Nathansswell