在Windows操作系统中,使用CMD进行小游戏开发是一个相对简单且高效的方法。下面是一个基本的小游戏示例:创建一个简单的文本冒险游戏。,,``batch,@echo off,,:menu,cls,echo 1. Continue,echo 2. Exit,set /p choice=Choose an option:,if %choice%==1 goto continue,if %choice%==2 exit,,:continue,cls,echo Welcome to the Adventure Game!,echo You find yourself in a mysterious forest.,echo You must choose your path wisely.,,:east,echo You walk east into the forest and come across a small stream.,set /p action=east?,if "%action%"=="look" goto look,if "%action%"=="go" goto goeast,,:west,echo You walk west towards the entrance of the forest.,set /p action=west?,if "%action%"=="look" goto look,if "%action%"=="go" goto gowest,,:look,echo You see a beautiful butterfly resting on a flower.,set /p action=look?,if "%action%"=="pick up" goto pickup,,:pickup,echo You pick up the butterfly and it flies away.,goto endgame,,:geopark,echo You enter a hidden park filled with exotic plants.,set /p action=geopark?,if "%action%"=="explore" goto explore,if "%action%"=="take photos" goto takephotos,if "%action%"=="go back" goto goback,,:explore,echo You explore the park for hours and discover a hidden cave.,set /p action=explore?,if "%action%"=="enter cave" goto entercave,if "%action%"=="leave cave" goto leavecave,,:entercave,echo You enter the cave and find treasure!,set /p action=entercave?,if "%action%"=="claim" goto claimtreasure,if "%action%"=="leave cave" goto leavecave,,:leavecave,echo You leave the cave and return to the park.,set /p action=leavecave?,if "%action%"=="return to geopark" goto returntogeopark,if "%action%"=="go back" goto goback,,:takephotos,echo You take some amazing photos and decide to leave the park early.,set /p action=takephotos?,if "%action%"=="quit" goto quitgame,if "%action%"=="go back" goto goback,,:returntogeopark,echo You return to the Geopark after exploring all its wonders.,set /p action=returntogeopark?,if "%action%"=="exit" goto endgame,,:quitgame,echo Thanks for playing! The game has ended.,,:endgame,pause,
``,,这个脚本实现了基本的文本冒险游戏功能,包括选择路径、探索环境和与NPC互动。你可以根据需要扩展这个游戏的功能,比如添加更多的场景、对话和谜题。
@echo off REM 检查任务栏窗口标题是否为 "运行*" if "%WindowTitle%"=="运行*" ( REM 结束 Notepad++ 缓存进程 taskkill /f /im notepad++.exe > nul ) else ( REM 启动 Notepad++ start /max "" notepad++.exe ping -n 6 127.0.0.1 > nul ) pause
这个脚本会在任务栏上显示一个提示信息:“运行*”,然后检查当前窗口标题是否与“运行*”匹配,如果匹配,则会杀死 Notepad++ 的缓存进程;否则,它将启动 Notepad++,脚本暂停等待用户输入以保持界面可见。
0