【问题标题】:Trying to make a cmd game/sim尝试制作 cmd 游戏/sim
【发布时间】:2014-03-05 22:14:25
【问题描述】:

我正在尝试制作一个 cmd 游戏/sim。但数字不会改变!我觉得自己像个磨砂膏,我可能是个大白痴...这是所有代码,如果您想对我大喊大叫,请使用

*YELLING* text here *YELLING*

所有代码:

@echo off
title Gold Economics Sim. 2014

goto info

:info
set/a money=100000
set/a gold=10
set/a gldpk=31300
set/a golda=0
set/a moneya=0

goto begin

->:tstpg
->cls
->echo You have %money% Dollar
->echo You have %gold% KG gold
->echo The gold price is %gldpk% Dollar
->echo How much gold do you want?
->
->:tstpgc
->set/p tstpgc=""
->goto buytst
->
->:buytst
->set/a golda=gold+testpgc
->set/a moneya=money-testpgc*gldph
->
->goto tstpg2
->
->:tstpg2
->echo You have %moneya% Dollar
->echo You have %golda% KG gold
->echo The gold price is %gldpk% Dollar
->pause

:begin
cls
echo ==============================================================================
echo                                  Main Menu
echo ==============================================================================
echo  Welcome to Gold Economics Sim. 2014! The goal of this 'Game' is to earn
echo  as much money as you can in three-four years. There's also a custom mode where
echo  you can edit all the game settings! Hope you enjoy this preview game!
echo(
echo  Type "start"          to begin
echo  Type "options"        to change the settings
echo  Type "help"           to get help
echo  Type "quit" or "exit" to quit
echo(
echo V0.1
echo ==============================================================================

:beginc
set/p beginc=""
if "%beginc%"=="start" goto start
if "%beginc%"=="help" goto help
if "%beginc%"=="options" goto options
if "%beginc%"=="quit" exit
if "%beginc%"=="exit" exit
if "%beginc%"=="test page" goto tstpg 
if "%beginc%"=="clean" goto begin
echo Sorry, but I don't understand that.
goto beginc

如果这只是一个愚蠢的小错误,我很抱歉,我为此沮丧了一个小时并且无法修复它,所以我希望这里有人可以修复它?如果您提供帮助、尝试修复、修复或未修复,我会将您记入积分。

编辑:很抱歉,我没有很好地解释我的问题/问题,我还没有使用 if "%beginc%"=="options" goto options 的东西。那是我的错误。问题是带有这些箭头 (->) 的代码不会改变。

【问题讨论】:

  • 代码中没有开始标签:if "%beginc%"=="start" goto start
  • if /i "%beginc%"=="text" 也将/i 添加到您的比较中,然后字母大小写无关紧要。
  • 哇,我不知道 foxidrive,谢谢。你解决了我在其他游戏中遇到的问题!

标签: cmd calculator simulator


【解决方案1】:

最大的问题是缺少目的地。

if "%beginc%"=="start" goto start
if "%beginc%"=="help" goto help
if "%beginc%"=="options" goto options
if "%beginc%"=="quit" exit
if "%beginc%"=="exit" exit
if "%beginc%"=="test page" goto tstpg 
if "%beginc%"=="clean" goto begin

:start:options:help 尚未在代码中的任何位置定义。

关于 Windows Batch 是否适合任何语言,请参阅 RosettaCode 上的 batch language solutions

【讨论】:

  • 很抱歉,我没有真正说出我的问题是什么,我感到沮丧和疲倦,并没有真正检查所有内容。我还没有使用 :start,... 的东西。只需 :tstpg 进行测试。谢谢和抱歉。
  • 嘿,没问题。发生在我们所有人身上。
【解决方案2】:

哦,我明白了,您没有任何适当的 if 变量,例如: 如果你想让对方在输入 PLAY 时开始,你需要这个:

echo THE FRAME UP HERE!
set /p P1=
if %P1% equ PLAY goto PLAY_1
if %P1% neq PLAY goto MENU

(P1是要调用的变量)

(neq 不是必需的,但它可以让你打错字,而不是杀死 cmd.exe)

【讨论】:

    猜你喜欢
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    相关资源
    最近更新 更多