Sketch won't run help needed !VERY URGENT!

edited January 2017 in Questions about Code

okay so in my other question I asked how to do file I/O to make a high score table for my two player game I am making for my computer studies summative and my code was working and now whenever I try to run it, it just says cannot run sketch and it doesn't tell my why it can't run. Here is my code

[mod edit, was too long to format, reduced to highscore code]

String[] lines;
String[] lines2 ;
String scoreList2;
String scoreList;
...

//Scoring and health 
int Score1;
int Score2;
int Health1 = 200 ;
int Health2 = 200 ;

void setup() {
  size(1210, 681);
...  
   lines = loadStrings("highScore.txt");
   lines = loadStrings("highScore2.txt");
}

void draw() {
...


  {
    if (key=='p')
    {
      if (lines.length<5)
      {
        lines=append(lines, str(Score1));
      } else
      {
        if (parseInt(lines[lines.length-1])<Score1)

        {
          lines[lines.length-1]=str(Score1);
          for (int i=lines.length-1; i>0; i--)

          {
            if (parseInt(lines[i])>parseInt(lines[i-1]))

            {
              String setScoreLower=lines[i-1];
              lines[i-1]=lines[i];
              lines[i]=setScoreLower;

            }
          }
        }
        scoreList="";
        for (int i = 0; i < lines.length; i++)

        {
          scoreList+=lines[i]+" ";

        }
        saveStrings("highScore.txt", lines);

      }

      sort(lines);

    }

    //println(lines);
    println("scoreList  "+scoreList);

  }
    if (key=='o')
    {
      if (lines2.length<5)
      {
        lines2=append(lines2, str(Score2));
      } else
      {
        if (parseInt(lines2[lines2.length-1])<Score2)

        {
          lines2[lines2.length-1]=str(Score2);
          for (int z=lines.length-1; z>0; z--)

          {
            if (parseInt(lines2[z])>parseInt(lines2[z-1]))

            {
              String setScoreLower2=lines2[z-1];
              lines2[z-1]=lines2[z];
              lines2[z]=setScoreLower2;

            }
          }
        }
        scoreList2="";
        for (int z = 0; z< lines2.length; z++)

        {
          scoreList2+=lines2[z]+" ";

        }
        saveStrings("highScore2.txt", lines2);

      }

      sort(lines2);

    }
}

so can you tell me if there is something wrong with it

Tagged:

Answers

  • ok, format your code correctly please

    go back edit your post (small gear wheel|Edit)

    then select entire code with the mouse (blank line before and after it)

    hit ctrl-o OR the C in the command bar

  • it wont let me post it then it says it to long

  • if (((De3==0)&&(Z2>=L2)&&(Z2<=L2+127))) 
    

    jesus. did they not teach you anything about meaningful variable names?

  • when it did run and now not anymore, it's always because of what you changed last (maybe i/o?)

    can you post ALL those lines correctly that you recently changed?

    formatted correctly please

  • i don't think it's the code. (and the code's really no use to us as it is because it needs two fonts and a dozen images to run)

    do you have an nvidia video card? what driver version are you using?

    (there have been a few reports lately of sketches not working after a nvidia driver update)

    but here's the highscore code:

      {
        if (key=='p') {
          if (lines.length<5) {
            lines=append(lines, str(Score1));
          } else {
            if (parseInt(lines[lines.length-1])<Score1) {
              lines[lines.length-1]=str(Score1);
              for (int i=lines.length-1; i>0; i--) {
                if (parseInt(lines[i])>parseInt(lines[i-1])) {
                  String setScoreLower=lines[i-1];
                  lines[i-1]=lines[i];
                  lines[i]=setScoreLower;
                }
              }
            }
            scoreList="";
            for (int i = 0; i < lines.length; i++){
              scoreList+=lines[i]+" ";
            }
            saveStrings("highScore.txt", lines);
          }
          sort(lines);
        }
        //println(lines);
        println("scoreList  "+scoreList);
      }
    
        if (key=='o'){
          if (lines2.length<5){
            lines2=append(lines2, str(Score2));
          } else{
            if (parseInt(lines2[lines2.length-1])<Score2) {
              lines2[lines2.length-1]=str(Score2);
              for (int z=lines.length-1; z>0; z--) {
                if (parseInt(lines2[z])>parseInt(lines2[z-1])) {
                  String setScoreLower2=lines2[z-1];
                  lines2[z-1]=lines2[z];
                  lines2[z]=setScoreLower2;
                }
              }
            }
            scoreList2="";
            for (int z = 0; z< lines2.length; z++) {
              scoreList2+=lines2[z]+" ";
            }
            saveStrings("highScore2.txt", lines2);
          }
          sort(lines2);
        }
    
Sign In or Register to comment.