Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- SetLocal ENABLEDELAYEDEXPANSION
- REM While it was created as an independent game, it was created as a proof of concept for action scenes in Rariquest, which REM I never implemented.
- echo TROLL SLAYER
- echo -
- :start
- REM intilize
- set /a heroX= 1
- set /a heroY= 1
- set /a trollX= 9
- set /a trollY= 6
- set /a westwall= 0
- set /a eastwall= 10
- set /a northwall= 0
- set /a southwall= 7
- set /a rockX= 6
- set /a rockY= 4
- set /a swordX= %eastwall% + 1
- set /a swordY= %southwall% + 1
- set heroChar= @
- set trollChar= T
- set rockChar= O
- set swordChar= +
- set heroD= W
- set swordOut= false
- :loop
- REM reset background
- set /a y= %northwall%
- :outer
- set /a x= %westwall%
- :inner
- set char%y%_%x%= .
- set /a x= x + 1
- if %x% LEQ %eastwall% goto inner
- set /a y= y + 1
- if %y% LEQ %southwall% goto outer
- REM add walls
- set /a x= %westwall%
- :northwall
- set char%northwall%_%x%= -
- set /a x= x + 1
- if %x% LEQ %eastwall% goto :northwall
- set /a x= %westwall%
- :southwall
- set char%southwall%_%x%= -
- set /a x= x + 1
- if %x% LEQ %eastwall% goto :southwall
- set /a y= %northwall%
- :westwall
- set char%y%_%westwall%= -
- set /a y= y + 1
- if %y% LEQ %southwall% goto :westwall
- set /a y= %northwall%
- :eastwall
- set char%y%_%eastwall%= -
- set /a y= y + 1
- if %y% LEQ %southwall% goto :eastwall
- REM add objects
- set char%heroY%_%heroX%=%heroChar%
- set char%trollY%_%trollX%=%trollChar%
- set char%rockY%_%rockX%=%rockChar%
- set char%swordY%_%swordX%=%swordChar%
- REM display
- set /a y= %northwall%
- :outer1
- set displayline=
- set /a x= %westwall%
- :inner1
- set displayline=%displayline% !char%y%_%x%!
- set /a x= x + 1
- if %x% LEQ %eastwall% goto inner1
- echo %displayline%
- set /a y= y + 1
- if %y% LEQ %southwall% goto outer1
- REM character eaten if under troll
- set character=!char%heroY%_%heroX%!
- if %character%==%trollChar% goto gameover
- REM troll slain if under sword
- set character=!char%trollY%_%trollX%!
- if %character%==%swordChar% goto win
- set swordOut= false
- REM move character (WASD)
- set /a nheroY = %heroY%
- set /a nheroX = %heroX%
- choice /c QWASDZ /n /t 1 /d Q
- if %errorlevel%==2 set /a nheroY= heroY - 1
- if %errorlevel%==2 set heroD=W
- if %errorlevel%==3 set /a nheroX= heroX - 1
- if %errorlevel%==3 set heroD=A
- if %errorlevel%==4 set /a nheroY= heroY + 1
- if %errorlevel%==4 set heroD=S
- if %errorlevel%==5 set /a nheroX= heroX + 1
- if %errorlevel%==5 set heroD=D
- if %errorlevel%==6 set swordOut=true
- REM prevent moving into walls and rocks
- set return= retChar
- set char=hero
- goto walls
- :retChar
- REM update characters location
- set /a heroX = %nheroX%
- set /a heroY = %nheroY%
- set char%heroY%_%heroX%=%heroChar%
- REM move troll (random)
- set /a ntrollY = %trollY%
- set /a ntrollX = %trollX%
- set dir= %random%
- set /a dir= dir - ( (dir / 5) * 5)
- if %dir%==1 set /a ntrollY= trollY - 1
- if %dir%==2 set /a ntrollX= trollX - 1
- if %dir%==3 set /a ntrollY= trollY + 1
- if %dir%==4 set /a ntrollX= trollX + 1
- REM prevent moving into walls and rocks
- set return= retTroll
- set char=troll
- goto walls
- :retTroll
- REM update trolls location
- set /a trollX = %ntrollX%
- set /a trollY = %ntrollY%
- REM move sword in if sword is out
- if %swordOut%==true goto sword
- set /a swordX= %eastwall% + 1
- set /a swordY= %southwall% + 1
- goto loop
- :sword
- echo WHOA
- REM move sword
- set /a nswordX= heroX
- set /a nswordY= heroY
- if %heroD%==W set /a nswordY= %heroY% - 1
- if %heroD%==A set /a nswordX= %heroX% - 1
- if %heroD%==S set /a nswordY= %heroY% + 1
- if %heroD%==D set /a nswordX= %heroX% + 1
- REM prevent moving into walls and rocks
- set return= retSword
- set char=sword
- goto walls
- :retSword
- REM update swords location
- set /a swordX = %nswordX%
- set /a swordY = %nswordY%
- goto loop
- :walls
- REM set char and return before calling
- set /a nY= !n%char%Y!
- set /a nX= !n%char%X!
- if %nX%==%westwall% goto block
- if %nX%==%eastwall% goto block
- if %nY%==%northwall% goto block
- if %nY%==%southwall% goto block
- set destination=!char%nY%_%nX%!
- if %destination%==%rockChar% goto block
- goto %return%
- :block
- echo "THUD^!"
- set /a n%char%X= !%char%X!
- set /a n%char%Y= !%char%Y!
- goto %return%
- :gameover
- echo You ams eaten by a troll.
- pause
- goto retry
- :win
- echo You ams slay the troll.
- pause
- goto retry
- :retry
- echo -
- echo Ams plays again?
- choice
- if %errorlevel%==1 goto start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement