@echo off
setlocal enabledelayedexpansion
title 虚拟驾驶模拟器
color 0a
mode con: cols=80 lines=25
:: 路线数据库
set "route1=长沙到北京:1280"
set "route2=广州到哈尔滨:3220"
set "route3=成都到上海:1960"
set "route4=昆明到乌鲁木齐:3910"
:: ASCII艺术图形
echo.
echo ██████╗ ██╗ ██╗███████╗██╗██████╗ ██████╗
echo ██╔════╝ ██║ ██║██╔════╝██║██╔══██╗██╔═══██╗
echo ██║ ███╗██║ ██║█████╗ ██║██║ ██║██║ ██║
echo ██║ ██║██║ ██║██╔══╝ ██║██║ ██║██║ ██║
echo ╚██████╔╝╚██████╔╝██║ ██║██████╔╝╚██████╔╝
echo ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝
:main_menu
cls
echo ================== 路线选择 ==================
echo 1. 京广线:长沙 -> 武汉 -> 郑州 -> 北京 (1280公里)
echo 2. 南北大通道:广州 -> 长沙 -> 武汉 -> 哈尔滨 (3220公里)
echo 3. 长江经济带:成都 -> 重庆 -> 武汉 -> 上海 (1960公里)
echo 4. 西部走廊:昆明 -> 成都 -> 兰州 -> 乌鲁木齐 (3910公里)
echo =============================================
set /p route=请选择路线编号:
if "%route%"=="1" set "total=1280" & set "path=长沙 武汉 郑州 北京"
if "%route%"=="2" set "total=3220" & set "path=广州 长沙 武汉 哈尔滨"
if "%route%"=="3" set "total=1960" & set "path=成都 重庆 武汉 上海"
if "%route%"=="4" set "total=3910" & set "path=昆明 成都 兰州 乌鲁木齐"
set "current_speed=0"
set "distance=0"
set "cruise=0"
set "start_time=%time%"
:driving_loop
echo ■■■■■■■■■■■■■■ 仪表盘 ■■■■■■■■■■■■■■
echo 当前路段:!path!
echo 剩余里程:%total% 公里
echo 当前车速:!current_speed! 公里/小时
echo 行驶时间:%elapsed_time%
echo ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
echo [操作选项]
echo 1. 加速(+20km/h) 2. 减速(-20km/h)
echo 3. 定速巡航 4. 退出驾驶
choice /c 1234 /n /m "请选择操作:"
set "input=%errorlevel%"
if %input% equ 1 set /a "current_speed+=20"
if %input% equ 2 set /a "current_speed-=20"
if %input% equ 3 set "cruise=1" & echo 已启用定速巡航模式
if %input% equ 4 goto end_journey
:: 速度限制(0-120km/h)
if !current_speed! lss 0 set "current_speed=0"
if !current_speed! gtr 120 set "current_speed=120"
:: 计算时间差
set "end_time=%time%"
call :calc_time_diff "%start_time%" "%end_time%" elapsed_time
:: 计算行驶距离(每秒更新)
set /a "hours=!elapsed_time::=*60+0!" 2>nul
set /a "hours=(hours)/3600"
set /a "distance=current_speed*hours"
set /a "total-=distance"
if %total% leq 0 (
echo ★★★★★ 到达目的地!★★★★★
echo 总耗时:!elapsed_time!
pause
exit
)
timeout /t 1 /nobreak >nul
goto driving_loop
:calc_time_diff
setlocal
set "start=%~1"
set "end=%~2"
set /a "start_h=!start:~0,2!*3600 + !start:~3,2!*60 + !start:~6,2!"
set /a "end_h=!end:~0,2!*3600 + !end:~3,2!*60 + !end:~6,2!"
set /a "diff=end_h - start_h"
if %diff% lss 0 set /a "diff+=86400"
set /a "hours=diff/3600"
set /a "minutes=(diff%%3600)/60"
set /a "seconds=diff%%60"
endlocal & set "%3=%hours%小时%minutes%分%seconds%秒"
goto :eof
:end_journey
echo 行程已终止,共行驶:!distance! 公里
目录
@echo off
setlocal enabledelayedexpansion
title 虚拟驾驶模拟器
color 0a
mode con: cols=80 lines=25
:: 路线数据库
set "route1=长沙到北京:1280"
set "route2=广州到哈尔滨:3220"
set "route3=成都到上海:1960"
set "route4=昆明到乌鲁木齐:3910"
:: ASCII艺术图形
echo.
echo ██████╗ ██╗ ██╗███████╗██╗██████╗ ██████╗
echo ██╔════╝ ██║ ██║██╔════╝██║██╔══██╗██╔═══██╗
echo ██║ ███╗██║ ██║█████╗ ██║██║ ██║██║ ██║
echo ██║ ██║██║ ██║██╔══╝ ██║██║ ██║██║ ██║
echo ╚██████╔╝╚██████╔╝██║ ██║██████╔╝╚██████╔╝
echo ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝
echo.
:main_menu
cls
echo.
echo ================== 路线选择 ==================
echo.
echo 1. 京广线:长沙 -> 武汉 -> 郑州 -> 北京 (1280公里)
echo 2. 南北大通道:广州 -> 长沙 -> 武汉 -> 哈尔滨 (3220公里)
echo 3. 长江经济带:成都 -> 重庆 -> 武汉 -> 上海 (1960公里)
echo 4. 西部走廊:昆明 -> 成都 -> 兰州 -> 乌鲁木齐 (3910公里)
echo.
echo =============================================
echo.
set /p route=请选择路线编号:
if "%route%"=="1" set "total=1280" & set "path=长沙 武汉 郑州 北京"
if "%route%"=="2" set "total=3220" & set "path=广州 长沙 武汉 哈尔滨"
if "%route%"=="3" set "total=1960" & set "path=成都 重庆 武汉 上海"
if "%route%"=="4" set "total=3910" & set "path=昆明 成都 兰州 乌鲁木齐"
set "current_speed=0"
set "distance=0"
set "cruise=0"
set "start_time=%time%"
:driving_loop
cls
echo.
echo ■■■■■■■■■■■■■■ 仪表盘 ■■■■■■■■■■■■■■
echo.
echo 当前路段:!path!
echo.
echo 剩余里程:%total% 公里
echo 当前车速:!current_speed! 公里/小时
echo 行驶时间:%elapsed_time%
echo.
echo ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
echo.
echo [操作选项]
echo 1. 加速(+20km/h) 2. 减速(-20km/h)
echo 3. 定速巡航 4. 退出驾驶
echo.
choice /c 1234 /n /m "请选择操作:"
set "input=%errorlevel%"
if %input% equ 1 set /a "current_speed+=20"
if %input% equ 2 set /a "current_speed-=20"
if %input% equ 3 set "cruise=1" & echo 已启用定速巡航模式
if %input% equ 4 goto end_journey
:: 速度限制(0-120km/h)
if !current_speed! lss 0 set "current_speed=0"
if !current_speed! gtr 120 set "current_speed=120"
:: 计算时间差
set "end_time=%time%"
call :calc_time_diff "%start_time%" "%end_time%" elapsed_time
:: 计算行驶距离(每秒更新)
set /a "hours=!elapsed_time::=*60+0!" 2>nul
set /a "hours=(hours)/3600"
set /a "distance=current_speed*hours"
set /a "total-=distance"
if %total% leq 0 (
echo.
echo ★★★★★ 到达目的地!★★★★★
echo 总耗时:!elapsed_time!
pause
exit
)
timeout /t 1 /nobreak >nul
goto driving_loop
:calc_time_diff
setlocal
set "start=%~1"
set "end=%~2"
set /a "start_h=!start:~0,2!*3600 + !start:~3,2!*60 + !start:~6,2!"
set /a "end_h=!end:~0,2!*3600 + !end:~3,2!*60 + !end:~6,2!"
set /a "diff=end_h - start_h"
if %diff% lss 0 set /a "diff+=86400"
set /a "hours=diff/3600"
set /a "minutes=(diff%%3600)/60"
set /a "seconds=diff%%60"
endlocal & set "%3=%hours%小时%minutes%分%seconds%秒"
goto :eof
:end_journey
echo.
echo 行程已终止,共行驶:!distance! 公里
pause
exit