处理中的Speed Typer游戏

时间:2019-12-09 20:52:44

标签: processing

游戏思路很简单:单词出现在屏幕上,您必须尽快键入它们。 我对此有一些疑问:

int points = 0;
int miss = 0;

String input = "";

void setup(){
   size(640,360);
 }

void draw(){
   background(0);
   show();

fill(0,255,0);

text ("> "+input, 15, 350); 
text ("| " + "Points : " + points, 190, 350);
text ("| " + "Miss : " + miss, 350, 350);

}

void show(){
  frameRate(0.5);
  String[] words = {"a", "b", "c", "d", "e",
                  "f", "g", "h", "i", "l",
                  "m", "n", "o", "p", "q"};

  int index = int(random(words.length));

  fill(255);
  noStroke();
  text(words[index],width/2-10,height/2);

  if(key == ENTER || key == RETURN && input == words[index]){
    input = "";
 }
  else
   points++;
}

  void keyPressed(){
    if (key==ENTER||key==RETURN) {

  } else
      input = input + key;
   }

主要问题是键入速度太慢,我尝试使用frameRate和Delay进行操作,但似乎不起作用。还有一个很大的问题是,如果我输入一个随机字母,它将自动给我一个分数,因为我没有指定我输入的特定字母必须等于屏幕上出现的特定字母。有小费吗?谢谢你们

0 个答案:

没有答案