1.

Solve : Guidance to making an Adventure game using batch??

Answer»

Hello,

I'd like to know how to be able to make an adventure game using batch. One looking pretty much like this, with the option of moving around, getting items, equipment window, fighting, all that things (though, the possibility of getting items and having an equipment window is not that important);

^/\^^/\^^/\^^/\^^/\^^/\^^^ ^ / /\ = Mountains
###############X#####- X = Character
####-T-##~~~~# -#- T = Tower
####-###~~~~# -#- # = Grass tile
############ -#- - = Walls
#### -#- ~ = Water.

Yeah, I guess you get the basic idea. I just don't know where to START. No idea how I should code to even be able to move around! Let alone creating texts popping up at parts (for story-telling purposes), etc.

Is there any tutorial on how to do this? If not, where should I start? Please do not direct me to a guide with 5000 lines of unrelated things, and 2 lines related things.

Oh, and sorry if this seems like a freakishly stupid question. I can't really help that I know nothing. A helping hand would be appreciated. Making small games like this is DEFINITELY something I want to do. As a hobby, of course.



Thanks,

Velocigendo.other people have created batch file games on this forum, i was the first that i know of to create an adventure game, even though i called it an rpg.. when i created (diablos batch game) which is now called (realms of *censored*) , im going to WRITE you a short tutorial

I really dont understand what you where trying to explain, with the mountains and ect.. but this will be helpfull anyways..


For movement, you dont need to anticipate every move the player will make
but it is better to, first off you need user input.. so use set /p using set with the /p SWITCH will cause a variable to be set with the typed input as set pauses and waits for it, for example.. typing set /p c=- would echo - and wait for you to type a value for the variable, so for example.. typing set /p c=- then typing test as it pauses would set c as test "%c%", now that you have the input what to do with it, theres two types of input in any basic game.. in my way of thinking anyways,they are movement and actions , when i started i used the set variable and a bunch of if statements, if "%c%"=="n" goto north and ect.. but it is better to use a seperate file, and a for command for example, in area RoomId you set the input as S there was two available options , S and E, you have a for command underneith the set /p command

set /p c=-
for /f "tokens=1*" %%a in (%V1%\v%rmid%) do if "%%a"=="%c%" (%%b) ELSE Cls&Echo Invalid Choice&Goto Section


using for /f and tokens will run through the file %v1%\v the files name is v%rmid% and %v1% is the file path in this example. , using a single token.. for sets two new variables from the file, %%a and %%b
Inside the file write something similar to this

S goto Roomid
E goto Roomid2


the variable %%a will be set as s and e and %%b will be Goto RoomId in this case the variable set %C% was set as s, so using the single if statement , if "%%a"=="%c%" (%%b) else goto section would Goto S "RoomId" , and if S or E wasnt an option it would Goto The Current Section (Area/Room).

Inside Every Room you should have its section name set into variable, this is the Roomid variable, for example

:Roomid
set rmid=RoomId
set /p c=-
for /f "tokens=1*" %%a in (%v1%\v%rmid%) do if "%%a"=="%c%" (%%b) ELSE Cls&Echo Invalid Choice&Goto Section


::Adding commands,
once you have figured out movement, regular commands become easy just add another for and if combination line, but instead of using multiple files "v%rmid%" use one file for all the rooms, %v1%\v inside %v1%\v write a few lines similar to the one in the %v1%\v%rmid% files, example : sleep goto sleep and then have a section called sleep inside your batch file.


Thanks. Shall try that out.

Oh, and about the mountains and all; That's just how I want the game to look like. You'll have letters/numbers/character based tiles to move around on. The mountains specifically are just supposed to enclose you to a certain area.


When will you ''release'' the Realms of H**l thing? It sounds very interesting (I read the topic).Regarding movement:

You will need to echo tiles based on position as variables. So you will have variables which will be set as mountains, grass, yourself, or whatever.

So your grid will look like this:
Code: [Select]%a% %b% %c% %d%
%e% %f% %g% %h%

You would set your starting place as
Code: [Select]set a=X
Which would make you start at grid 1a.

For movement you would do something like:

Code: [Select]set /p direction=Direction:
If %direction%==d goto right
:right
if %a%==X (set a=# & set b=X)This sets 1a back to the grass, but then moves you to 1b. You would need to go and echo the variables again so you can see the change of course.

Hope I am of help.
Here is what I have managed to knock up:
Use W,A,S and D to move. Its only short and you cannot get past the log.

Code: [Select]@echo off
:original
set A=o
set B=#
set C=#
set D=#
set E=#
set F=#
set G=#
set H=#
set I=#
set J=#
set K=#
set L=#
set M=#
set N=#
set O=#
set P=#
set Q=#
:map
cls
echo.
echo [ MapAdventure V1.0.1 ]
echo [/\^^^^/\^^/\^^^^/\^^/\^^/\^^/\^^^^/\^^/\^^/\^^^^/\^^/\^^/]
echo [/\^^/\^^/\^^^^/\^^/\^^/\^^/\^^^^/\^^/\^^/\^^/\^^/\^^/\^^]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~%A%%B%~~~~~~~~~##################~~~]
echo [~~~~~~~~~%C%%D%~~~~~~####~~~~~~~~~~~~##.##~~~]
echo [~~~~~~~~~%E%%F%~~~~~~####~~~~~~~~~~~~#####~~~]
echo [~~~~~~~~~%G%%H%-######~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [ ~=Water,/\=Mountain,#=Land,o=You,-=Log ]
If %H%==o (
echo [ Note: You cannot cross the log. ]
)
:movement
set /p Direc= [Type Direction:
:direction
If %Direc%==w goto w
If %Direc%==W goto w
IF %Direc%==a goto a
IF %Direc%==A goto a
IF %Direc%==s goto s
IF %Direc%==S goto s
IF %Direc%==d goto d
IF %Direc%==D goto d
exit
:w
If %A%==o (set A=o)
If %B%==o (set B=o)
If %C%==o (
set C=#
set A=o
goto map
)
If %D%==o (
set D=#
set B=o
goto map
)
If %E%==o (
set E=#
set C=o
goto map
)
If %F%==o (
set F=#
set D=o
goto map
)
If %G%==o (
set G=#
set E=o
goto map
)
If %H%==o (
set H=#
set F=o
goto map
)
:a
If %B%==o (
set B=#
set A=o
goto map
)
If %D%==o (
set D=#
set C=o
goto map
)
If %F%==o (
set F=#
set E=o
goto map
)
If %H%==o (
set H=#
set G=o
goto map
)
If %A%==o (goto map)
If %C%==o (goto map)
If %E%==o (goto map)
If %G%==o (goto map)
:s
If %G%==o (goto map)
If %H%==o (goto map)
If %A%==o (
set A=#
set C=o
goto map
)
If %B%==o (
set B=#
set D=o
goto map
)
If %C%==o (
set C=#
set E=o
goto map
)
If %D%==o (
set D=#
set F=o
goto map
)
If %E%==o (
set E=#
set G=o
goto map
)
If %F%==o (
set F=#
set H=o
goto map
)
:d
If %A%==o (
set A=#
set B=o
goto map
)
If %C%==o (
set C=#
set D=o
goto map
)
If %E%==o (
set E=#
set F=o
goto map
)
If %G%==o (
set G=#
set H=o
goto map
)
If %D%==o (goto map)
If %B%==o (goto map)
If %F%==o (goto map)
If %H%==o (goto map)
:safety pause
pause >nul
Code: [Select]If %Direc%==w goto w
If %Direc%==W goto w
IF %Direc%==a goto a
IF %Direc%==A goto a
IF %Direc%==s goto s
IF %Direc%==S goto s
IF %Direc%==d goto d
IF %Direc%==D goto d
why not use if /I ?

Code: [Select]If /I %Direc%==w goto w
IF /I %Direc%==a goto a
IF /I %Direc%==s goto s
IF /I %Direc%==d goto dYes, that I forgot..



Discussion

No Comment Found