请说明您的终端浏览器的原因.你为什么使用Lynx或Elinks?他们如何帮助您进行编程?
我想创建一个基于文本的浏览器游戏,那我该怎么办呢?我可以在asp或jsp或php中进行编程,这不是障碍,但我不知道在尝试制作此类游戏时需要遵循的步骤.所以请指导我.
还请推荐一种用于制作相同的编程语言.
我正在尝试编写一个基于文本的基本游戏,因为我正在学习Java.我希望能够在游戏中计算轮次,以此来管理某些事件的节奏.例如,更换房间可以限制为每轮一次(在测试代码中为一秒).小型生物可能以更高的速率攻击或更换房间,而较大的房间可能更麻烦.目前很好?大.
所以,我把它煮熟了,立刻意识到每次while循环等待玩家输入命令时我都会碰到一个块.码:
private void startPlaying() {
//declare clock/round variables.
int lastRound = 0;
int currentRound = 0;
long lastTime = System.currentTimeMillis();
long currentTime;
while (player.getIsPlaying()){
//Clocking
currentTime = System.currentTimeMillis();
if ((lastTime + 1000) < currentTime) {
lastTime = currentTime;
lastRound = currentRound;
currentRound++;
System.out.println("Current round:\t" + currentRound + "\tCurrent time:\t" + currentTime); //EDIT:NOTE: This is just a test line to observe the loop.
}//end if (Clocking)
Command command = new Command();
String[] commandString = command.setAll(); //Array gets parsed elsewhere.
player.doCommand(commandString); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个基于终端的备份程序,我正在寻找一些创建基于文本的进度条的C++代码.我知道你可以用\ b自己实现它但我想我会看看是否已经有任何精心构建的实现.我最喜欢的基于文本的进度条的实现是pacman在arch linux上的进度条.
我的项目是用C++(Qt4)创建的.
这可能吗?我看过的每个答案都不是我想要的.我所做的就像是omega-rpg
(这是一个很棒的基于文本的debian RPG),但是在Python而不是C.我已经四处寻找并发现了一些东西,但没有任何与我正在做的事情相关的东西.是否更容易使用raw_input()
/ input
,或者使用某种API这样做会更有效吗?
打扫干净:
我需要一个Python实时键盘输入系统,但我不知道使用API或仅使用它是否更容易raw_input() / input()
.如果最好使用API,这对初学者级程序员来说是最好的?
额外:
任何解决方案都将用于基于文本的游戏!请在回答时记住这一点.
好的,我现在有一个目标是进行基本的文本冒险.但是,要做到这一点,我需要/想要一个可以执行以下操作的switch语句:
我怎么做到这一点?你能告诉我这个具体例子的编码吗:
提示用户输入数据.switch语句将"look box"视为一种情况,并将"sleep"视为另一种情况.程序不关心任何单词的顺序,但是关心字母的顺序.
请详细解释一切.我刚刚开始编码.
编辑:谢谢你的所有答案.我知道有更好,更复杂,更有用的处理方法,但它还不是我的水平.
我正在为Mac OS X v10.6构建这个应用程序
我正在构建一个基于文本的冒险,我创建了一个非常简单的自然语言解析器,可以处理用户键入的命令.到目前为止它工作得很好并且可以解析句子,例如:"拿剑"或"在盒子里看"
我要做的是为不同的单词创建一个别名列表,使输入命令不那么严格.因此,例如"take"可能具有别名"grab"或"go"可能具有别名"move,walk,or travel"
我已经尝试创建一个NSDictionary,其中键是单词,值是一个别名的NSArray.问题是,当确定输入的命令是否与可用命令匹配时,我将不得不使用用于密钥的单词引用别名.
我希望能够使用任何别名来引用任何其他别名.有谁知道这样做的好方法?
我的另一个想法(但似乎效率低下)是将每组别名存储在一个数组中.在解析时,我会找到包含我想要匹配的单词的数组,并尝试匹配该数组中的所有其他单词.
我有兴趣创建一个类似于Zork的基于文本的游戏.源代码并没有给出太多,很明显,文本输入是由php使用post方法提交的,并且页面被重新加载.
我应该从哪里开始?
我目前正在python中进行简单的文本冒险.基本上我希望randint选择1或2然后分配给right_wire,然后raw_input为wire_choice,然后匹配2以提供所需的结果.我相信你们可以弄清楚我到底想做什么.我在这附近还是离开了?谢谢!
right_wire = randint(1, 2)
wrong_wire = 0
if right_wire == 1:
wrong_wire = 2
elif right_wire == 2:
wrong_wire = 1
else:
print "ERROR"
while True:
print "Which wire do you pull?"
print
print "1. The red one."
print "2. The blue one."
print
wire_choice = raw_input('*>>*')
if wire_choice == 1 and right_wire == 1:
print "**BOMB DEFUSED**"
return 'engineering2'
elif wire_choice == 2 and right_wire == 2:
print "**BOMB DEFUSED**"
return 'engineering2'
elif wire_choice == 1 and right_wire …
Run Code Online (Sandbox Code Playgroud) 我有一个叫做攻击的功能:
def attack(name,minmultiplier,maxmultiplier,critchance,attacker,attackee):
print(attacker[0],"used",name)
multiplier=random.randint(minmultiplier,maxmultiplier)
crit=random.randint(critchance,100)
if crit==100 and ((attacker[2]*multiplier*2)-attackee[3]) > 0:
attackee[1]=attackee[1]-((attacker[2]*multiplier*2)-attackee[3])
elif ((attacker[2]*multiplier)-attackee[3]) > 0:
attackee[1]=attackee[1]-((attacker[2]*multiplier)-attackee[3])
else:
print("You fail to hit",attackee[0])
print(attackee[0],"'s health after",attacker[0],"'s attack is",attackee[1])
Run Code Online (Sandbox Code Playgroud)
我正在为老板和玩家做一些实际的攻击:
boss=["Greed",1000,10,10,1]
slashp=attack("slash",1,2,5,player,boss)
slashb=attack("slash",1,2,5,boss,player)
kick=attack("kick",1,1,1,player,boss)
aiattacklist=[slashb]
attacknamelist=["slash","kick"]
attackfunclist=[slashp,kick]
Run Code Online (Sandbox Code Playgroud)
即使我只将这些版本保存为变量,它们仍然被调用:
template used slash
You fail to hit Greed
Greed 's health after template 's attack is 1000
Greed used slash
template 's health after Greed 's attack is 58
template used kick
You fail to hit Greed
Greed 's health after template 's …
Run Code Online (Sandbox Code Playgroud) def start():
import os
os.system("cls")
print "*A Wise man once said “Be the change that you wish to see in the world.” This is the idea you have decided to live by and strive for in your quest for making a better world. You are Noah Vis, CEO of the tech giant GAIA and currently the richest man in the world, surpassing the likes of Bill Gates and Waren Buffet by a great margin. Born into a life of modest …
Run Code Online (Sandbox Code Playgroud) 所以我的朋友和我正在尝试制作一个基于文本的视频游戏,我一直在研究如何降低编程.这是我们迄今为止的c ++程序:
#include <iostream>
#include <stdio.h>
char Choice;
using namespace std;
int main()
{
printf("You wake up to darkness.\n");
printf("Confused and tired, you walk to the nearest house.\n");
printf("You notice it's abandoned. What do you do?\n");
printf("1. Walk Away.\n");
printf("2. Jump.\n");
printf("3. Open Door.\n");
printf("Choose wisely.\n");
cin >> Choice;
if(Choice=1)
{
printf("The House seems to have a gravital pull on you. How strange.\n");
}
else if(Choice=2)
{
printf("Having Fun?\n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是当我构建并运行它时,它将显示所有内容,但所有答案都将是if(Choice = 1)答案.我的程序中是否缺少某些需要或部分相互矛盾的东西?
text-based ×12
python ×4
adventure ×3
browser ×2
c++ ×2
api ×1
c# ×1
elinks ×1
function ×1
if-statement ×1
input ×1
java ×1
lynx ×1
nlp ×1
objective-c ×1
php ×1
python-2.7 ×1
python-3.x ×1
raw-input ×1
string ×1
syntax ×1
syntax-error ×1
system-clock ×1
terminal ×1