Solved how to make an enemy in a batch rougelike game

October 29, 2013 at 11:21:48
Specs: Windows 7
im trying to make a zombie theamed rouge like game in batch but I cant seem to find out how to add the zombies in the map to follow the player...please don't say "batch is a crappy programing language" I know this I just want to do this in batch...can anyone help me?

See More: how to make an enemy in a batch rougelike game

Report •

✔ Best Answer
October 30, 2013 at 19:54:55
Ok, here's a sample that demos a hint on how to do this ascii-screen manipulation using batch. (This was my answer to a post about a year ago.I've added the 45 degree (diagonal) movess as well (7,9,1,3) but I don't have the motivation to make it a working game with enemies and bullets. Viewing the code, you can see the concept, but of course there are other ways to code the concept, probably much better than this:
::====== begin script
@echo off
setlocal enabledelayedexpansion
:SETUP
set H=1
set V=1
:M...........................M
set space=M...........................M
for /L %%a in (1,1,10) do set L%%a=%space%
set L0=%L1:M=o%
set L0=%L0:.=Z%
set L11=%L0%
set E=1
set HH=27
set VV=10
set left=M
set right=.
set from=M..
set move=M@.
set t1=M
set t2=.

:GAME

set z=.
set zz=@
:game1
set L%V%=!L%V%:%from%=%move%!
if %move% equ x (
set from=x
set move=@
)

:SHOOT

cls
for /L %%a in (0,1,%VV%) do echo !L%%a!
echo %L11%
echo %H% %V%
set zz=@
set z=.

:aa
rem 123456
rem 825q64
choice /c:123456789q /n :
set /a rt=%errorlevel%"%%"3
goto :%errorlevel%
goto :game

:10
exit /b

:6 right
set /a H+=1
echo HHHHHHHHH %H% %left%
rem pause
REM if "%left%" equ "M" (
set left=.
set right=.
if %H% equ 2 (
set left=
set t1=
)
if %H% gtr %HH% (
set right=%zz%
set left=.
set H=%HH%
set end=1

)
goto :move

:4 left
rem set /a H-=1
echo HHHHHHHHH %H% %right%
rem pause
echo right test:%right%:
rem if "%right%" equ "M" (
set left=.
set right=.
if %H% equ %HH% (
set right=
set t2=
)
set /a H-=1
if %H% EQU 0 (
set right=.
set left=%zz%
set H=1
echo fuk rt: !zz!
pause

)
goto :move

:5 shoot
set from=@
set move=x
set zz=x
goto :game

:1 move down-lft
set mo=1
if %V% neq %VV% call :vert
goto :4

:3 move down-rt
set mo=1
if %V% neq %VV% call :vert
goto :6

:7 move up-lft
set mo=-1
if %V% neq 1 call :vert
goto :4

:9 move up-rt
set mo=-1
if %V% neq 1 call :vert
goto :6

:2 move down
set mo=1
if %V% neq %VV% call :vert
goto :shoot

:8 move up
set mo=-1
if %V% neq 1 call :vert
goto :shoot

:vert
set hold=!L%V%!
set hold=!hold:x=.!
set L%V%=%space%
::set L%V%=!L%V%:%zz%=.!
set /a V+=mo
::echo v: %v%
::echo hold: %hold%
set L!V!=!hold!
goto :eof

:move
if %H% lss 0 (
set from=M%zz%.
set move=M.%zz%
goto :move2
) else (
set from=%zz%.
set move=.%zz%
)

if %H% equ %HH% (
set from=%zz%.M
set move=.%zz%M
goto :move2
)
set from=%left%%zz%%right%
if /i %rt% equ 0 (
set move=%t1%%t2%%zz%
) else (
set move=%zz%%t1%%t2%
)
:move2
set t1=.
set t2=.
echo zz: %zz%
echo %from% from: left zz right
echo %move% to: t1 t2 zz
echo H %H% zz: %zz%
rem pause
if "%left%" neq "%H%" set left=.
set "%right%" neq "%H%" set right=.
goto :game1
::==== end script. i left the disabled debugging stuff, cause i figure you will need it.
I might work with this script some more, just for fun...

message edited by nbrane



#1
October 29, 2013 at 12:49:03
How have you designed the grid already? This should in theory be important. It seems to me that the problem will lie in ensureing that the zombies are tracking the charactor, It seems as though you will need to consider proximity already because of buildings and such. If you are already tracking the charactor, you will need to be able to compute differecnces. for example say you are using a simple grid as such

 1234567890
1  c
2
3     z
4     
5

For example the character would be at position 3,1, zombie at 6,3. From there you would either subtract from the x or y axis, and the zombie would move closer. The trick will be deciding how random you want it, and how aggressive.

::mike

message edited by mikelinus


Report •

#2
October 30, 2013 at 05:55:38
firehawk4nzzz: can anyone help me?
You're using batch. There is no help. Doing this in literally any other language is easier. If you want a command line interface, use PowerShell ISE. After you set the script execution policy to allow, it's a decent setup. If you don't, you end up with a scripting environment that doesn't run scripts, and that's silly. Almost as silly as using batch.

How To Ask Questions The Smart Way


Report •

#3
October 30, 2013 at 06:04:07
ok so on that subject how would one set up an interactive grid in which a character could move through...In other words how would I make a map and be able to have the player navigate through it with zombies

Report •

Related Solutions

#4
October 30, 2013 at 19:54:55
✔ Best Answer
Ok, here's a sample that demos a hint on how to do this ascii-screen manipulation using batch. (This was my answer to a post about a year ago.I've added the 45 degree (diagonal) movess as well (7,9,1,3) but I don't have the motivation to make it a working game with enemies and bullets. Viewing the code, you can see the concept, but of course there are other ways to code the concept, probably much better than this:
::====== begin script
@echo off
setlocal enabledelayedexpansion
:SETUP
set H=1
set V=1
:M...........................M
set space=M...........................M
for /L %%a in (1,1,10) do set L%%a=%space%
set L0=%L1:M=o%
set L0=%L0:.=Z%
set L11=%L0%
set E=1
set HH=27
set VV=10
set left=M
set right=.
set from=M..
set move=M@.
set t1=M
set t2=.

:GAME

set z=.
set zz=@
:game1
set L%V%=!L%V%:%from%=%move%!
if %move% equ x (
set from=x
set move=@
)

:SHOOT

cls
for /L %%a in (0,1,%VV%) do echo !L%%a!
echo %L11%
echo %H% %V%
set zz=@
set z=.

:aa
rem 123456
rem 825q64
choice /c:123456789q /n :
set /a rt=%errorlevel%"%%"3
goto :%errorlevel%
goto :game

:10
exit /b

:6 right
set /a H+=1
echo HHHHHHHHH %H% %left%
rem pause
REM if "%left%" equ "M" (
set left=.
set right=.
if %H% equ 2 (
set left=
set t1=
)
if %H% gtr %HH% (
set right=%zz%
set left=.
set H=%HH%
set end=1

)
goto :move

:4 left
rem set /a H-=1
echo HHHHHHHHH %H% %right%
rem pause
echo right test:%right%:
rem if "%right%" equ "M" (
set left=.
set right=.
if %H% equ %HH% (
set right=
set t2=
)
set /a H-=1
if %H% EQU 0 (
set right=.
set left=%zz%
set H=1
echo fuk rt: !zz!
pause

)
goto :move

:5 shoot
set from=@
set move=x
set zz=x
goto :game

:1 move down-lft
set mo=1
if %V% neq %VV% call :vert
goto :4

:3 move down-rt
set mo=1
if %V% neq %VV% call :vert
goto :6

:7 move up-lft
set mo=-1
if %V% neq 1 call :vert
goto :4

:9 move up-rt
set mo=-1
if %V% neq 1 call :vert
goto :6

:2 move down
set mo=1
if %V% neq %VV% call :vert
goto :shoot

:8 move up
set mo=-1
if %V% neq 1 call :vert
goto :shoot

:vert
set hold=!L%V%!
set hold=!hold:x=.!
set L%V%=%space%
::set L%V%=!L%V%:%zz%=.!
set /a V+=mo
::echo v: %v%
::echo hold: %hold%
set L!V!=!hold!
goto :eof

:move
if %H% lss 0 (
set from=M%zz%.
set move=M.%zz%
goto :move2
) else (
set from=%zz%.
set move=.%zz%
)

if %H% equ %HH% (
set from=%zz%.M
set move=.%zz%M
goto :move2
)
set from=%left%%zz%%right%
if /i %rt% equ 0 (
set move=%t1%%t2%%zz%
) else (
set move=%zz%%t1%%t2%
)
:move2
set t1=.
set t2=.
echo zz: %zz%
echo %from% from: left zz right
echo %move% to: t1 t2 zz
echo H %H% zz: %zz%
rem pause
if "%left%" neq "%H%" set left=.
set "%right%" neq "%H%" set right=.
goto :game1
::==== end script. i left the disabled debugging stuff, cause i figure you will need it.
I might work with this script some more, just for fun...

message edited by nbrane


Report •

Ask Question