Help with a project (game to guess words)

ok thanks so much for your help

1 Like

in the start menu you must click “s”

but this is also the first letter in snow. Bad.

use Space Bar instead == ' '

ok thanks for the tip

1 Like

also, here in the level 1 the order you type doesn’t matter



int timer= 6000; // timer for game
//int timer1=5000;
//int timer2=4000;

String type= "________";
int i=0;


PImage xmas1, xmas2, xmas5, xmas12, xmas9;
PFont font; // referenced from Meri Engel Youtube video "Adding and using fonts in processing"
// idea for font sourced from Susan Alden

// either have delay(500) at the start of game or have Mousepressed to start game
int gameLevel; // game level is implemented

// ----------------------------------------------------------------

void setup() {
  size(626, 417, P2D);

  //minim = new Minim(this);
  //song = minim.loadFile("song.mp3");
  //song.loop();
  font = createFont("font2.vlw", 16);
  // textFont(font);
  xmas1 = loadImage("xmas1.jpg");
  xmas5 = loadImage("xmas5.jpg");// load image and data into scene data structure( from lab 3 with Professor Stephen Brown)  xmas8 = loadImage("xmas8.jpg");//font = createFont(“ArialMT-48”, 225);
  xmas12 = loadImage("xmas12.jpg");
  xmas2 = loadImage("xmas2.png");
  xmas9 = loadImage("xmas9.jpg");
}

void draw() {
  background(0);
  switch(gameLevel) { // switch cases for startMenu, levels and the end

  case 0:
    startMenu();

    if (key == ' ') {
      type="____";
      gameLevel=1;
      // level1(); // NO
    } else {
      gameLevel=0;
    }
    break;

  case 1:
    level1();
    //println(type);
    fill(255);
    textSize(40); 
    text(type, 
      160, 400); //shows the letters the player guesses 
    break;

  case 2:
    level2();
    fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;

  case 3:
    level3();
    fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;

  case 4:
    restart();
    break;
  }
}

// ----------------------------------------------------------------

void startMenu() {
  background(0);

  // textFont(font, 30);
  fill(128, 128, 255);//lilac
  text("Welcome to Think Quik!", 100, 50);

  text("Press > < to start the game", 100, 100);
  text("Instructions: Use the Keyboard to type letters", 0, 200);
  text("for your guesses and good luck!", 0, 230);
  text("Rules: Guess the word before time runs out", 0, 280);
  text("Hints are given for the word on each level", 0, 310);
}

void level1() {
  background(0);
  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textFont(font);
  textSize(25);
  text("Hint: Usually falls in Winter", 100, 100); // hint for the player to guess the word

  String word = "snow";
  String guess = "";

  if (keyPressed) {
    for (int i = 0; i < word.length(); i++) {
      if (i<word.length() && key == word.charAt(i)) { // if the character’s key equals any letter in the word prints word to screen
        int i_3=0;
        String t_=""; 
        for (char c : word.toCharArray()) { 
          if (i_3!=i) 
            t_ +=  type.charAt(i_3);
          else 
          t_ +=c;
          i_3++;
        }//for 

        type = t_;    // key;
        // println(type) ;
        i++;
      } else if (key=='\n')
      {
        type="";
      } // hitting enter results in the null pointer exception
    }
  }

  // }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed

  fill(0);
  textFont(font);
  textSize(40);
  text(guess, 160, 250);

  for (int a =0; a < guess.length(); a++) {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3))
    {
      fill(255, 0, 0); 
      text("You WON", 111, 311); 
      if (keyPressed&&key==' ') {
        gameLevel=2; // if the word is guessed then player moves to next level
        timer=5000;
        type="_______";
        i=0;
        delay(500);
      }
    }
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
}

void level2() {
  background(0);

  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Christmas Tree decoration", 100, 100); // hint for the player to guess the word

  String word = "baubles";
  String guess = ""; 
  int len= word.length();
  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen
    {

      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
          len= len-i_3; // int length change implemented by Cian Burke.

        else 
        t_ +=c;
        i_3++;
        len = len-i_3;
      }//for 

      type += t_;    // key;
      //println(type);
      i++;
    }
  }//println(type);

  // }
  guess += key + type;
  guess = guess.toUpperCase(); 
  for (int a =0; a < guess.length(); a++)
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4)
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6))
    {
      gameLevel=3; // if the word is guessed then player moves to next level
      timer=4000;
      type="";
      i=0;
      delay(500);
    }
  }
  fill(0);
  textSize(40);
  text(guess, 160, 250);

  if (timer == 0)
  {
    exit(); //if the timer runs out before player
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
}

void level3()
{
  background(0);
  String word = "reindeer";
  String guess = ""; 
  int len= word.length();
  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Santa's pets", 160, 100); // hint for the player to guess the word

  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen and if its the same length
    {

      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
          len= len-i_3;

        else 
        t_ +=c;
        i_3++;
        len = len-i_3;
      }//for 

      type += t_;    // key;
      //println(type);
      i++;
    }
  }//println(type);


  // }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed
  for (int a =0; a < guess.length(); a++) // verifies to see if every guessed letter is correct
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4) 
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6)
      && word.charAt(7)==type.charAt(7))
    {
      gameLevel=4; // player moves to restart()
      i=0;
    }
  }
  fill(0);
  textSize(40);
  text(guess, 160, 250);
  if (timer == 0)
  {
    exit();
  }

  timer--;
  fill(0);
  textSize(25);
  text(timer, 490, 50);
}

void restart() // when the game is won, screen pops up to prompt the player if they wih to play again.
{
  background(0);
  fill(0, 255, 0);
  textSize(50);
  text("Press >y< to play again", 50, 150);
  text("Press >n< to leave game", 50, 250);
  text("Congrats on winning", 50, 350);
  if (key == 'y')
  {
    gameLevel=1; //player returns to startMenu() to play again.
    type="____"; 
    delay(500);
  } else if (key == 'n')
  {
    exit(); // exits the game if they dont want to play again.
  }
}

so does that mean whenever i type o or w itll add to the string?

it’ll add yeah

since we have ____ at first it’ll replace _n_w

Chrisir

i tried this out in a new sketch and it still goes in order- as in i need to type snow as s-n-o-w to win

int timer= 6000; // timer for game
//int timer1=5000;
//int timer2=4000;

String type= "________";
int i=0;


PImage xmas1, xmas2, xmas5, xmas12, xmas9;
PFont font; // referenced from Meri Engel Youtube video "Adding and using fonts in processing"
// idea for font sourced from Susan Alden

// either have delay(500) at the start of game or have Mousepressed to start game
int gameLevel; // game level is implemented

// ----------------------------------------------------------------

void setup() {
  size(626, 417, P2D);

  //minim = new Minim(this);
  //song = minim.loadFile("song.mp3");
  //song.loop();
  font = createFont("font2.vlw", 16);
  // textFont(font);
  xmas1 = loadImage("xmas1.jpg");
  xmas5 = loadImage("xmas5.jpg");// load image and data into scene data structure( from lab 3 with Professor Stephen Brown)  xmas8 = loadImage("xmas8.jpg");//font = createFont(“ArialMT-48”, 225);
  xmas12 = loadImage("xmas12.jpg");
  xmas2 = loadImage("xmas2.png");
  xmas9 = loadImage("xmas9.jpg");
}

void draw() {
  background(0);
  switch(gameLevel) { // switch cases for startMenu, levels and the end

  case 0:
    startMenu();

    if (key == ' ') {
      type="____";
      gameLevel=1;
      // level1(); // NO
    } else {
      gameLevel=0;
    }
    break;

  case 1:
    level1();
    //println(type);
    fill(255);
    textSize(40); 
    text(type, 
      160, 400); //shows the letters the player guesses 
    break;

  case 2:
    level2();
    fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;

  case 3:
    level3();
    fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;

  case 4:
    restart();
    break;
  }
}

// ----------------------------------------------------------------

void startMenu() {
  background(0);

  // textFont(font, 30);
  fill(128, 128, 255);//lilac
  text("Welcome to Think Quik!", 100, 50);

  text("Press > < to start the game", 100, 100);
  text("Instructions: Use the Keyboard to type letters", 0, 200);
  text("for your guesses and good luck!", 0, 230);
  text("Rules: Guess the word before time runs out", 0, 280);
  text("Hints are given for the word on each level", 0, 310);
}

void level1() {
  background(0);
  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textFont(font);
  textSize(25);
  text("Hint: Usually falls in Winter", 100, 100); // hint for the player to guess the word

  String word = "snow";
  String guess = "";

  if (keyPressed) {
    for (int i = 0; i < word.length(); i++) {
      if (i<word.length() && key == word.charAt(i)) { // if the character’s key equals any letter in the word prints word to screen
        int i_3=0;
        String t_=""; 
        for (char c : word.toCharArray()) { 
          if (i_3!=i) 
            t_ +=  type.charAt(i_3);
          else 
          t_ +=c;
          i_3++;
        }//for 

        type = t_;    // key;
        // println(type) ;
        i++;
      } else if (key=='\n')
      {
        type="";
      } // hitting enter results in the null pointer exception
    }
  }

  // }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed

  fill(0);
  textFont(font);
  textSize(40);
  text(guess, 160, 250);

  for (int a =0; a < guess.length(); a++) {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3))
    {
      fill(255, 0, 0); 
      text("You WON", 111, 311); 
      if (keyPressed&&key==' ') {
        gameLevel=2; // if the word is guessed then player moves to next level
        timer=5000;
        type="_______";
        i=0;
        delay(500);
      }
    }
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
}

void level2() {
  background(0);

  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Christmas Tree decoration", 100, 100); // hint for the player to guess the word

  String word = "baubles";
  String guess = ""; 
  int len= word.length();
  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen
    {

      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
          len= len-i_3; // int length change implemented by Cian Burke.

        else 
        t_ +=c;
        i_3++;
        len = len-i_3;
      }//for 

      type += t_;    // key;
      //println(type);
      i++;
    }
  }//println(type);

  // }
  guess += key + type;
  guess = guess.toUpperCase(); 
  for (int a =0; a < guess.length(); a++)
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4)
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6))
    {
      gameLevel=3; // if the word is guessed then player moves to next level
      timer=4000;
      type="";
      i=0;
      delay(500);
    }
  }
  fill(0);
  textSize(40);
  text(guess, 160, 250);

  if (timer == 0)
  {
    exit(); //if the timer runs out before player
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
}

void level3()
{
  background(0);
  String word = "reindeer";
  String guess = ""; 
  int len= word.length();
  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Santa's pets", 160, 100); // hint for the player to guess the word

  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen and if its the same length
    {

      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
          len= len-i_3;

        else 
        t_ +=c;
        i_3++;
        len = len-i_3;
      }//for 

      type += t_;    // key;
      //println(type);
      i++;
    }
  }//println(type);


  // }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed
  for (int a =0; a < guess.length(); a++) // verifies to see if every guessed letter is correct
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4) 
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6)
      && word.charAt(7)==type.charAt(7))
    {
      gameLevel=4; // player moves to restart()
      i=0;
    }
  }
  fill(0);
  textSize(40);
  text(guess, 160, 250);
  if (timer == 0)
  {
    exit();
  }

  timer--;
  fill(0);
  textSize(25);
  text(timer, 490, 50);
}

void restart() // when the game is won, screen pops up to prompt the player if they wih to play again.
{
  background(0);
  fill(0, 255, 0);
  textSize(50);
  text("Press >y< to play again", 50, 150);
  text("Press >n< to leave game", 50, 250);
  text("Congrats on winning", 50, 350);
  if (key == 'y')
  {
    gameLevel=1; //player returns to startMenu() to play again.
    type="____"; 
    delay(500);
  } else if (key == 'n')
  {
    exit(); // exits the game if they dont want to play again.
  }
}

ahh nevermind it worked sorry but only for level 1, so do i have to change it for level 2?

1 Like

yeah, up to now, each level is a separate

thanks for the help, i’ll give it a shot if i wanted to count how many letters each person guessed for each level would i have a global variable and the a private variable for each level?

have a global variable and reset it to 0 for each level

so eg at the end of level 1 in the if statement for the “You Win”
count=0;?

yes

that’s it

Chrisir

1 Like

thank you so much chrisir

1 Like

I was unable to wrap my head around it as when i have the for loop multiple letters will print, im guessing i need another var but im not sure, does this for loop make the character into an array? also when i put {} for the if and else i get a null point error is it cuz of this for command? Im sorry for asking so many questions I’ll keep trying and update you if i get the code working


int timer= 6000; // timer for game
//int timer1=5000;
//int timer2=4000;

String type= "________";
int i=0;


PImage xmas1,xmas2,xmas5,xmas12,xmas9;
PFont font; // referenced from Meri Engel Youtube video "Adding and using fonts in processing"
// idea for font sourced from Susan Alden

// either have delay(500) at the start of game or have Mousepressed to start game
int gameLevel; // game level is implemented

void setup()
{
  size(626, 417, P2D);

  minim = new Minim(this);
  song = minim.loadFile("song.mp3");
  song.loop();
  font = loadFont("font2.vlw");
  textFont(font);
  xmas1 = loadImage("xmas1.jpg");
  xmas5 = loadImage("xmas5.jpg");// load image and data into scene data structure( from lab 3 with Professor Stephen Brown)  xmas8 = loadImage("xmas8.jpg");//font = createFont(“ArialMT-48”, 225);
 xmas12 = loadImage("xmas12.jpg");
 xmas2 = loadImage("xmas2.png");
 xmas9 = loadImage("xmas9.jpg");
}

void draw()
{
  background(0);
  switch(gameLevel) // switch cases for startMenu, levels and the end
  {
  case 0:
    startMenu();

    if (key == ' ')
    {
      gameLevel=1;
     
      // level1(); // NO
    }
    else 
    {
      gameLevel=0;
    }
    break;

  case 1:
    level1();
    //println(type);
      fill(255);
    textSize(40); 
    text(type,  
      160, 400); //shows the letters the player guesses 
    break;

  case 2:
    level2();
     fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;

  case 3:
    level3();
       fill(255);
    textSize(40);
    text(type, 
      160, 400); 
    break;
    
    case 4:
    restart();
    break;
   
  }
}

void startMenu()
{
  background(xmas1);

  textFont(font, 30);
 fill(128,128,255);//lilac
  text("Welcome to Think Quik!", 100, 50);
  
  
  text("Press >SpaceBar< to start the game", 100, 100);
  text("Instructions: Use the Keyboard to type letters", 0, 200);
  text("for your guesses and good luck!", 0, 230);
  text("Rules: Guess the word before time runs out", 0, 280);
  text("Hints are given for the word on each level",0,310);
}

void level1()
{
  background(xmas12);
  fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textFont(font);
  textSize(25);
  text("Hint: Usually falls in Winter", 100, 100); // hint for the player to guess the word

  String word = "snow";
  String guess = "";

 
  if (keyPressed) {
    for (int i = 0; i < word.length(); i++) {
      if (i<word.length() && key == word.charAt(i)) { // if the character’s key equals any letter in the word prints word to screen
        int i_3=0;
        String t_=""; 
        for (char c : word.toCharArray()) { 
          if (i_3!=i) 
            t_ +=  type.charAt(i_3);
          else 
          t_ +=c;
          i_3++;
        }//for 

        type = t_;    // key;
        // println(type) ;
        i++;
      } 
    }
  }

// }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed

  fill(0);
  textFont(font);
  textSize(40);
  text(guess, 160, 250);
  
for (int a =0; a < guess.length(); a++)
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3))
    {
     fill(255, 0, 0); 
      text("Hit space", 111, 311); 
      if (keyPressed&&key==' ') {
        gameLevel=2; // if the word is guessed then player moves to next level
        timer=5000;
        type="";
        i=0;
        delay(500);
      }
    }
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
}

void level2()
{
  background(xmas5);

 fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Christmas Tree decoration", 100, 100); // hint for the player to guess the word

  String word = "baubles";
  String guess = ""; 
int len= word.length();
//char replace= ' ';
  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
     for (int i = 0; i < word.length(); i++) 
       {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen
    {
      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
           len = len - i_3; // int length change implemented by Cian Burke.
       // t_ +=  type.charAt(len)
        else 
       // t_+= type.charAt(i_3);
        t_ += c;
        i_3++;
        len = len-i_3; // len takes away i_3 
      }
     //for     // key;
      //replace= word.charAt(i);
     type+=t_;
      i++;
    }
   }
  }
     
//println(type);
  

// }
  guess = key + type;
  guess = guess.toUpperCase(); 
  
 // int count =0;
  for (int a =0; a < guess.length(); a++)
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4)
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6))
    {
      gameLevel=3; // if the word is guessed then player moves to next level
      timer=4000;
      type="";
      i=0;
      delay(500);
    }
  }
  
 fill(0);
  textSize(40);
  text(guess, 160, 250);

  if(timer == 0)
  {
    exit(); //if the timer runs out before player
  }

  timer--;
  fill(255);
  textSize(25);
  text(timer, 500, 50);
  }


void level3()
{
  background(xmas2);
  String word = "reindeer";
  String guess = ""; 
int len= word.length();
fill(0);
  rect(80, 50, 400, 100);
  fill(255);
  textSize(25);
  text("Hint: Santa's pets", 160, 100); // hint for the player to guess the word

  //for (int i = 0; i < word.length(); i++)  {
  if (keyPressed)
  {
    if (i<word.length() && key == word.charAt(i)) // if the character’s key equals any letter in the word prints word to screen and if its the same length
    {
     
      int i_3=0;
      String t_=""; 
      for (char c : word.toCharArray()) { 
        if (i_3!=i)
           len = len - i_3;
          
        else 
        t_ +=c;
        i_3++;
         len = len-i_3;
      }//for 

      type = t_; 
      len= len-i;// key;
      i++;
    }
  }//println(type);
  

// }
  guess += key + type;
  guess = guess.toUpperCase(); // letters stay on screen but only print one and if line 129-132 is removed multiple letters get printed

  for (int a =0; a < guess.length(); a++) // verifies to see if every guessed letter is correct
  {
    if (word.length() == type.length() && 
      word.charAt(0)==type.charAt(0)
      && word.charAt(1)==type.charAt(1)
      && word.charAt(2)==type.charAt(2)
      && word.charAt(3)==type.charAt(3)
      && word.charAt(4)==type.charAt(4) 
      && word.charAt(5)==type.charAt(5)
      && word.charAt(6)==type.charAt(6)
      && word.charAt(7)==type.charAt(7))
    {
      gameLevel=4; // player moves to restart()
      i=0;
    }
  }
 fill(0);
  textSize(40);
  text(guess, 160, 250);
  if(timer == 0)
 {
   exit();
 }
    
  timer--;
  fill(0);
  textSize(25);
  text(timer, 490, 50);
  
  
  }

void restart() // when the game is won, screen pops up to prompt the player if they wih to play again.
{
  background(xmas9);
   fill(0,255,0);
  textSize(50);
  text("Press >y< to play again", 50, 150);
  text("Press >n< to leave game", 50, 250);
  text("Congrats on winning", 50, 350);
  if(key == 'y')
  {
    gameLevel=1; //player returns to level1 to play again.
    type="____";
    delay(500);
  }
  else if(key == 'n')
  {
    exit(); // exits the game if they dont want to play again.
  }
}
 

before setup()

String type= “________”;

WHY so many _____ ? just 4, because snow.

i changed it now , i honestly forgot i had that many thank you

When you get to the next level:

      if (keyPressed&&key==' ') {
        gameLevel=2; // if the word is guessed then player moves to next level
        timer=5000;
        type="";  // WHY? must be type="_______";  because   String word = "baubles";

I’m not quite understanding the following statement. Do you mean i have to rethink the reset type=“”; for the level 2 and that next level transition and i’ll eventually get to what i want?

I was just referring to how you set type in the wrong way

I am working on the program now, wait a second