Solved need help with roguelike game in batch

November 5, 2013 at 11:49:16
Specs: Windows 7
here is my code so far... it works great and all but I don't know how to make the "#" at g26 to act like a wall regardless of where you walk into it... I was thinking something like "if %value%+1 EQU 26 set VALUE=25" or in the other case "if %value%-1 EQU 26 set VALUE=27... but obviously that dosnt work or I would'nt need to ask this question lol... anyway if you could possibly tinker with this code and send it back to me with a "changelog" that would be so awesome
here's my code so far:
@echo off
set VALUE=10
call :template
set g10=@
goto display2
:template
set g1=#
set g2=#
set g3=#
set g4=/
set g5=#
set g7=#
set g8=#
set g9=#
set g10=.
set g11=.
set g12=.
set g13=.
set g14=.
set g15=#
set g16=#
set g17=.
set g18=.
set g19=.
set g20=.
set g21=.
set g22=#
set g23=#
set g24=.
set g25=.
set g26=#
set g27=.
set g28=.
set g29=#
set g30=#
set g31=.
set g32=.
set g33=.
set g34=.
set g35=.
set g36=#
set g37=#
set g38=#
set g39=#
set g40=#
set g41=#
set g42=#
set g43=#

goto :EOF
:display
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo %value%
echo.
echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%
echo %g37%%g38%%g39%%g40%%g41%%g42%%g43%

goto :EOF
:display1
if %value% GEQ 44 goto displayone
if %value% EQU 5 goto next_room
if %value% LSS 9 set /a VALUE=%VALUE%+7
if %value% GTR 36 set /a VALUE=%VALUE%-7
if %value% EQU 2 set VALUE=10
if %Value% EQU 9 set VALUE=10
if %value% EQU 3 set VALUE=11
if %value% EQU 4 set VALUE=12
if %value% EQU 5 set VALUE=13
if %value% EQU 6 set VALUE=14
if %value% EQU 7 set VALUE=14
if %value% EQU 15 set VALUE=14
if %value% EQU 16 set VALUE=17
if %value% EQU 22 set VALUE=21
if %value% EQU 23 set VALUE=24
if %value% EQU 29 set VALUE=28
if %value% EQU 30 set VALUE=31
if %value% EQU 36 set VALUE=35
if %value% EQU 38 set VALUE=31
if %value% EQU 39 set VALUE=32
if %value% EQU 40 set VALUE=33
if %value% EQU 41 set VALUE=34
if %value% EQU 42 set VALUE=35
call :template
set G%value%=@
goto display2
:display2
call :display
if %value% LEQ 35 goto prompt
if %value% GEQ 44 goto promptone
:prompt
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-7
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+7
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
goto display1
:promptone
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-0
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+0
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
goto display1
:END
cls
echo Are you sure you want to end the game?
echo (y/n)
choice /c:yn /N
if %errorlevel% EQU 1 exit
if %errorlevel% EQU 2 goto Display2

:next_room
cls
echo next room
pause
exit

:displayone
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo.
echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%%g37%%g38%%g39%%g40%%g41%%g42%
echo %g43%%g44%%g45%%g46%%g47%%g48%%g49%%g50%%g51%%g52%%g53%%g54%%g55%
pause

message edited by firehawk4nzzz


See More: need help with roguelike game in batch

Report •

#1
November 5, 2013 at 14:44:19
✔ Best Answer
@echo off
set VALUE=10
call :template
set g10=@
::Added
set rock=26
goto display2
set bvalue=0
:template
set g1=#
set g2=#
set g3=#
set g4=/
set g5=#
set g7=#
set g8=#
set g9=#
set g10=.
set g11=.
set g12=.
set g13=.
set g14=.
set g15=#
set g16=#
set g17=.
set g18=.
set g19=.
set g20=.
set g21=.
set g22=#
set g23=#
set g24=.
set g25=.
set g26=#
set g27=.
set g28=.
set g29=#
set g30=#
set g31=.
set g32=.
set g33=.
set g34=.
set g35=.
set g36=#
set g37=#
set g38=#
set g39=#
set g40=#
set g41=#
set g42=#
set g43=#
goto :EOF

:display
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo %value%
echo.

echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%
echo %g37%%g38%%g39%%g40%%g41%%g42%%g43%
goto :EOF

:display1
if %value% GEQ 44 goto displayone
if %value% EQU 5 goto next_room
::added impenetrable rock
if %value% EQU %rock% set /a value=%bvalue%

if %value% LSS 9 set /a VALUE=%VALUE%+7
if %value% GTR 36 set /a VALUE=%VALUE%-7
if %value% EQU 2 set VALUE=10
if %Value% EQU 9 set VALUE=10
if %value% EQU 3 set VALUE=11
if %value% EQU 4 set VALUE=12
if %value% EQU 5 set VALUE=13
if %value% EQU 6 set VALUE=14
if %value% EQU 7 set VALUE=14
if %value% EQU 15 set VALUE=14
if %value% EQU 16 set VALUE=17
if %value% EQU 22 set VALUE=21
if %value% EQU 23 set VALUE=24
if %value% EQU 29 set VALUE=28
if %value% EQU 30 set VALUE=31
if %value% EQU 36 set VALUE=35
if %value% EQU 38 set VALUE=31
if %value% EQU 39 set VALUE=32
if %value% EQU 40 set VALUE=33
if %value% EQU 41 set VALUE=34
if %value% EQU 42 set VALUE=35
call :template
set G%value%=@
goto display2

:display2
call :display
if %value% LEQ 35 goto prompt
if %value% GEQ 44 goto promptone

:prompt

set /a bvalue=%VALUE%
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-7
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+7
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
::added
if %VALUE% equ %rock% echo set /a VALUE=%bvalue%

goto display1

:promptone

set /a bvalue=%VALUE%
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-0
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+0
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
::added
if %VALUE% equ %rock% set /a VALUE=%bvalue%

goto display1


:END
cls
echo Are you sure you want to end the game?
echo (y/n)
choice /c:yn /N
if %errorlevel% EQU 1 exit
if %errorlevel% EQU 2 goto Display2

:next_room
cls
echo next room
pause

:displayone
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo.
echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%%g37%%g38%%g39%%g40%%g41%%g42%
echo %g43%%g44%%g45%%g46%%g47%%g48%%g49%%g50%%g51%%g52%%g53%%g54%%g55%
pause

::mike

message edited by mikelinus


Report •

#2
November 5, 2013 at 15:46:37
this didn't work...in the file it pops up missing operand

Report •

#3
November 5, 2013 at 16:33:17
Its possibly because I don't have choice so run it off my flash drive when I want to use it

edited d:\choice.exe to choice
change to
if %VALUE% equ %rock% set /a VALUE=%bvalue%
instead of
added
if %VALUE% equ %rock% echo set /a VALUE=%bvalue%


::mike

message edited by mikelinus


Report •

Related Solutions

#4
November 5, 2013 at 20:38:26
I changed that so it would work but it popped up missing operand after that

Report •

#5
November 6, 2013 at 06:12:48
Variable expansion happens before expression parsing. Try putting your variables in double quotes (and pray your variable doesn't contain double quotes), or use delayed expansion. If that doesn't work, your error isn't on the IF line.
if "%VALUE%" equ "%rock%" set /a VALUE=bvalue

How To Ask Questions The Smart Way


Report •

#6
November 6, 2013 at 06:17:55
I did that but the same thing pops up

Report •

#7
November 6, 2013 at 06:21:41
Its weird, I ran the program again (after I changed the if line to not include echo)when I got back to my computer(instead of my phone) and it looked like I didn't get a missing operator error. do you know where it was occurring?

I even copied and pasted the code above and didn't get the error...wierd...

::mike

message edited by mikelinus


Report •

#8
November 6, 2013 at 07:53:51
firehawk4nzzz: I did that but the same thing pops up
So then you know your error isn't with the IF line. Keep echo on, run your script from a CMD window, and see where the error message pops up.

How To Ask Questions The Smart Way


Report •

#9
November 6, 2013 at 07:58:26
On another note, can you paste the program that you are running again, copied from the batch file if the above fails. Perhaps it a copy paste issue.

::mike


Report •

#10
November 6, 2013 at 08:09:39
@echo off
set VALUE=10
call :template
set g10=@
set rock=26
goto display2
set bvalue=0
:template
set g1=#
set g2=#
set g3=#
set g4=/
set g5=#
set g7=#
set g8=#
set g9=#
set g10=.
set g11=.
set g12=.
set g13=.
set g14=.
set g15=#
set g16=#
set g17=.
set g18=.
set g19=.
set g20=.
set g21=.
set g22=#
set g23=#
set g24=.
set g25=.
set g26=#
set g27=.
set g28=.
set g29=#
set g30=#
set g31=.
set g32=.
set g33=.
set g34=.
set g35=.
set g36=#
set g37=#
set g38=#
set g39=#
set g40=#
set g41=#
set g42=#
set g43=#

goto :EOF
:display
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo %value%
echo.
echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%
echo %g37%%g38%%g39%%g40%%g41%%g42%%g43%

goto :EOF
:display1
if %value% GEQ 44 goto displayone
if %value% EQU 5 goto next_room
if "%value%" EQU "%rock%" set /a value=%bvalue%
if %value% LSS 9 set /a VALUE=%VALUE%+7
if %value% GTR 36 set /a VALUE=%VALUE%-7
if %value% EQU 2 set VALUE=10
if %Value% EQU 9 set VALUE=10
if %value% EQU 3 set VALUE=11
if %value% EQU 4 set VALUE=12
if %value% EQU 5 set VALUE=13
if %value% EQU 6 set VALUE=14
if %value% EQU 7 set VALUE=14
if %value% EQU 15 set VALUE=14
if %value% EQU 16 set VALUE=17
if %value% EQU 22 set VALUE=21
if %value% EQU 23 set VALUE=24
if %value% EQU 29 set VALUE=28
if %value% EQU 30 set VALUE=31
if %value% EQU 36 set VALUE=35
if %value% EQU 38 set VALUE=31
if %value% EQU 39 set VALUE=32
if %value% EQU 40 set VALUE=33
if %value% EQU 41 set VALUE=34
if %value% EQU 42 set VALUE=35
call :template
set G%value%=@
goto display2
:display2
call :display
if %value% LEQ 35 goto prompt
if %value% GEQ 44 goto promptone
:prompt
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-7
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+7
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
if %VALUE% equ %rock% set /a VALUE=%bvalue%
goto display1
:promptone
choice /c:wsade /N
if %errorlevel% EQU 1 set /a VALUE=%VALUE%-0
if %errorlevel% EQU 2 set /a VALUE=%VALUE%+0
if %errorlevel% EQU 3 set /a VALUE=%VALUE%-1
if %errorlevel% EQU 4 set /a VALUE=%VALUE%+1
if %errorlevel% EQU 5 goto END
if %VALUE% equ %rock% echo set /a VALUE=%bvalue%
goto display1
:END
cls
echo Are you sure you want to end the game?
echo (y/n)
choice /c:yn /N
if %errorlevel% EQU 1 exit
if %errorlevel% EQU 2 goto Display2

:next_room
cls
echo next room
pause
exit

:displayone
cls
echo i made this...hahahahahahahaha!!!
echo use wasd to move or e to exit the program
echo.
echo %g1%%g2%%g3%%g4%%g5%%g7%%g8%
echo %g9%%g10%%g11%%g12%%g13%%g14%%g15%
echo %g16%%g17%%g18%%g19%%g20%%g21%%g22%
echo %g23%%g24%%g25%%g26%%g27%%g28%%g29%
echo %g30%%g31%%g32%%g33%%g34%%g35%%g36%%g37%%g38%%g39%%g40%%g41%%g42%
echo %g43%%g44%%g45%%g46%%g47%%g48%%g49%%g50%%g51%%g52%%g53%%g54%%g55%
pause
::when you run it missing operand pops up when you go over the "rock"

message edited by firehawk4nzzz


Report •

#11
November 6, 2013 at 08:14:48
...nevermind it works now lol It must have been a copy paste error...thank you for all the help

Report •

Ask Question