Introduction: Batch File: Basic Movement

Picture of Batch File: Basic Movement

Most of the techniques used to create movement in a Batch file I find are WAY more complicated than they need to be, so I created a basic version when I was bored. Enjoy!

Step 1: The Code

Just Copy and Paste the following code into a Notepad document and save it as "Movement.bat", then set it as "All Files", then press Save. Now you can open it and play! Enjoy!



@echo off

title Movement Test

:initsetup

set xcoord=3

set ycoord=3

:displaysetup

cls

set x1y1=

set x1y2=

set x1y3=

set x1y4=

set x1y5=

set x2y1=

set x2y2=

set x2y3=

set x2y4=

set x2y5=

set x3y1=

set x3y2=

set x3y3=

set x3y4=

set x3y5=

set x4y1=

set x4y2=

set x4y3=

set x4y4=

set x4y5=

set x5y1=

set x5y2=

set x5y3=

set x5y4=

set x5y5=

:display

set x%xcoord%y%ycoord%=X

echo.

echo Use WASD to move, or press P to quit.

echo.

echo ÉÍÍÍÍÍÍÍÍÍ»

echo º%x1y1% %x2y1% %x3y1% %x4y1% %x5y1%º

echo º%x1y2% %x2y2% %x3y2% %x4y2% %x5y2%º

echo º%x1y3% %x2y3% %x3y3% %x4y3% %x5y3%º

echo º%x1y4% %x2y4% %x3y4% %x4y4% %x5y4%º

echo º%x1y5% %x2y5% %x3y5% %x4y5% %x5y5%º

echo ÈÍÍÍÍÍÍÍÍͼ

choice /c swadp /n

set direction=%errorlevel%

goto direction%direction%

:direction1

set /a ycoord=%ycoord%+1

if %ycoord% GTR 5 (

set /a ycoord=%ycoord%-1

goto displaysetup

) else (

goto displaysetup

)

:direction2

set /a ycoord=%ycoord%-1

if %ycoord% LSS 1 (

set /a ycoord=%ycoord%+1

goto displaysetup

) else (

goto displaysetup

)

:direction3

set /a xcoord=%xcoord%-1

if %xcoord% LSS 1 (

set /a xcoord=%xcoord%+1

goto displaysetup

) else (

goto displaysetup

)

:direction4

set /a xcoord=%xcoord%+1

if %xcoord% GTR 5 (

set /a xcoord=%xcoord%-1

goto displaysetup

) else (

goto displaysetup

)

:direction5

cls

echo.

echo Are you sure you want to quit?

echo.

echo (Y/N)

choice /c yn /n

if %errorlevel%==1 exit

if %errorlevel%==2 goto initsetup

Comments

sethsdad (author)2016-04-08

Nice! Two suggestions though:

1.

echo "Use W ^"
echo "use S v"
echo "use A <"
echo "use D > to move, or press P to quit. "

shows how the keys work.

2. when the X shows up, the right hand wall moves out a space.

TheBigRoosterYo (author)sethsdad2016-04-11

I know. When I copy & pasted the code, it messed up some of it, and I'm too lazy to fix it :P

sethsdad (author)2016-04-08

Nice! Two suggestions though:

1.

echo "Use W ^"
echo "use S v"
echo "use A <"
echo "use D > to move, or press P to quit. "

shows how the keys work.

2. when the X shows up, the right hand wall moves out a space.