我想制作一个批量冒险游戏(不是基于文本的冒险),它为您提供选项,让您选择进行故事。
问题是我不知道如何在游戏中保存或加载进度,我想(可能)创建多个帐户,您可以从中断的地方开始。
我知道这是可能的,因为我在批量游戏中看到了它(我丢失了谁的文件)。那么,有谁知道这样做可能吗?
答案 0 :(得分:1)
@echo off
:menu
cls
echo 1.Sign in
echo 2.Register
echo 3.Exit
echo.
set /p input=What would you like to do:
if %input%==1 goto log
if %input%==2 goto reg
if %input%==3 goto exit
goto menu
:reg
cls
set /p user=Enter your desired username:
set /p pass="Enter your desired password:
echo %pass% >> %user%.txt
:: This will prompt for a username and password and then
:: output the user variable as the name of a .txt file that contains the
:: password
goto menu2
:log
set /p user="Enter your username: "
set /p pass="Enter your password: "
set /p password=<%user%.txt
pause >nul
:: This will check if the password entered is equal to the password in
:: the .txt file
if %pass% equ %password% goto menu2
goto menu
:menu2
::Enter your script here
当您删除评论时,系统会短得多。 :)
稍后在你的游戏中你可以使用与:reg标签中使用的系统相同的系统来创建一个包含玩家统计数据的批处理文件,也可能是其中的库存,例如set / a armor = 2和set / a sword = 1当你想向玩家展示他们的统计数据/库存时,请调用该文件。只是一个想法...无论如何,希望这有助于至少一点点。
答案 1 :(得分:0)
我正在制作游戏,这是登录注册,这是代码的一部分
@echo off
color f
:logsign
title whattodo?
cls
echo What will you do?
echo.
echo 1) Login
echo 2) Sign in
echo 3) Exit
echo.
set /p web=Type 1 or 2?
if "%web%"=="1" goto login
if "%web%"=="2" goto signup
if "%web%"=="3" exit
:notvalid
echo you're username is not valid.
echo.
echo please try again or sign up.
pause
cls
goto logsign
:notvalid1
echo you're password is not valid.
echo.
echo please try again or sign up.
pause
cls
goto logsign
:signup
title Sign Up
cls
echo What will be your username?
echo.
set /p username=Username:
echo %username% >%username%.bat
cls
echo What will be your password?
echo.
set /p password=Password:
echo %password%>>%username%.bat
cls
echo Go back to log in menu then log in.
pause
cls
goto logsign
:login
title login
cls
echo Let's start with name.What is it?
echo.
set /p username=Type username:
if not exist %username%.bat (goto notvalid)
pause
cls
echo Now what is your password?
echo.
set /p password=Type password:
if not exist %username%.bat (goto notvalid1)
pause
goto home
注册会保存用户并传入.bat文件
答案 2 :(得分:-1)
可能您可以将统计信息保存到以播放器配置文件命名的文件中,并读取该文件以查看它们在此处查看的位置。
How to read file contents into a variable in a batch file?