# Expecting EOF, found else

**URL:** <https://discourse.processing.org/t/expecting-eof-found-else/25759>\
**Category:** Beginners\
**Created:** [November 27, 2020, 3:53pm UTC](https://discourse.processing.org/t/expecting-eof-found-else/25759 "2020-11-27T15:53:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muffininwinter](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@muffininwinter](https://discourse.processing.org/u/muffininwinter)\
**Post date:** [November 27, 2020, 3:53pm UTC](https://discourse.processing.org/t/expecting-eof-found-else/25759/1 "2020-11-27T15:53:44Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

```auto
boolean running = false;
PImage imgbk;
PImage imgm;
PImage albert;
PImage imgnote;
String[] imageNames = { 
  "albert0.jpg", "albert1.jpg"
};
PImage[] images = new PImage[imageNames.length];
int numPeople = 2;
int dx, dy;
int score;
int startTime;
int albertX, albertY, albertW, albertH;

void setup() 
{
  size(850, 700);

  imgbk = loadImage("b.jpg");
  imgm = loadImage("m.jpg");
  imgnote = loadImage("n.png");
  for (int i = 0; i < imageNames.length; i=i++)
  { 
    String imageName = imageNames[i];
    images[i] = loadImage(imageName);
  }

  albertW = 150;
  albertH = 150;
  albertX = int(random(0, width-albertW));
  albertY = int(random(0, height/2-albertH));

  dx=5;
  dy=5;

  startTime = millis();
  score = 0;
}

void draw() {
  {
    fill(0);
    if ( score == -10) {
      textSize(50);
      fill(255, 0, 0);
      text("You Lose!", 150, 270);
    }
   else if (running) {
        image(imgm, 0, 0, width, height);
        image(imgnote, mouseX, mouseY, 100, 130);
        float r = random(0, 2); 
        int ir = int(r);
        PImage img = images[ir]; 
        image(img, 0, 0);

        albertX= albertX + dx;
        albertY= albertY + dy;
        textSize(48);
        fill(255, 255, 255);
        text("Time: "+ (millis() - startTime)/1000 + "s", 25, 50);
        text("Score: "+ score, 25, 100);

        if (albertX<0 || albertX>width-albertW)
        { 
          dx=-dx;
        }
        if (albertY<0 || albertY>height-albertH)
        { 
          dy=-dy;
        }

        if (albertX+albertW >= mouseX && albertX <= mouseX + 100 && albertY+albertH >= mouseY && albertY <= mouseY + 130)
        {
          score = score - 1;
          albertX = int(random(0, width-albertW));
          albertY = int(random(0, height/2-albertH));
        }
      }
  }
}
 else {
  image(imgbk, 0, 0, width, height);
  PFont myFont;
  myFont = loadFont("Rockwell-ExtraBold-65.vlw");
  textFont(myFont);
  fill(255);
  text("Start", 80, 400);
}
}
}

void mousePressed() {
  running = !running;
}

```

---

<div class="post-metadata">

**Author:** ![muffininwinter](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@muffininwinter](https://discourse.processing.org/u/muffininwinter)\
**Post date:** [November 27, 2020, 3:55pm UTC](https://discourse.processing.org/t/expecting-eof-found-else/25759/2 "2020-11-27T15:55:07Z")

</div>

i want to have a welcome screen at the beginning and the user need to press to start the game. Getting a -10 will lead to a game lose. Thank you so much!

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 27, 2020, 8:01pm UTC](https://discourse.processing.org/t/expecting-eof-found-else/25759/3 "2020-11-27T20:01:41Z")

</div>

Hi,

Nice tip : you can press `Ctrl+T` in the Processing editor to auto fomat your code ! 😉

After this operation, you can see that line `91`, the bracket is underlined with a red colored line :

![Capture d’écran de 2020-11-27 20-56-52](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fea55f190cef124821725ffe7c2457b1653ee6ab.png)

In Java and most of the other languages like C or JavaScript when you open a block (with barckets) you need to close it.

And also you added too much brackets in the `draw()` function, an empty block, I just removed it and added some blank lines to make the code more clear :

```auto
boolean running = false;
PImage imgbk;
PImage imgm;
PImage albert;
PImage imgnote;
String[] imageNames = { 
  "albert0.jpg", "albert1.jpg"
};
PImage[] images = new PImage[imageNames.length];
int numPeople = 2;
int dx, dy;
int score;
int startTime;
int albertX, albertY, albertW, albertH;

void setup() {
  size(850, 700);

  imgbk = loadImage("b.jpg");
  imgm = loadImage("m.jpg");
  imgnote = loadImage("n.png");

  for (int i = 0; i < imageNames.length; i=i++) { 
    String imageName = imageNames[i];
    images[i] = loadImage(imageName);
  }

  albertW = 150;
  albertH = 150;
  albertX = int(random(0, width-albertW));
  albertY = int(random(0, height/2-albertH));

  dx=5;
  dy=5;

  startTime = millis();
  score = 0;
}

void draw() {
  fill(0);

  if (score == -10) {
    textSize(50);
    fill(255, 0, 0);
    text("You Lose!", 150, 270);
  } else if (running) {
    image(imgm, 0, 0, width, height);
    image(imgnote, mouseX, mouseY, 100, 130);
    float r = random(0, 2); 
    int ir = int(r);
    PImage img = images[ir]; 
    image(img, 0, 0);

    albertX= albertX + dx;
    albertY= albertY + dy;
    textSize(48);
    fill(255, 255, 255);
    text("Time: "+ (millis() - startTime)/1000 + "s", 25, 50);
    text("Score: "+ score, 25, 100);

    if (albertX<0 || albertX>width-albertW) { 
      dx=-dx;
    }

    if (albertY<0 || albertY>height-albertH) { 
      dy=-dy;
    }

    if (albertX+albertW >= mouseX && albertX <= mouseX + 100 && albertY+albertH >= mouseY && albertY <= mouseY + 130) {
      score = score - 1;
      albertX = int(random(0, width-albertW));
      albertY = int(random(0, height/2-albertH));
    }
  } else {
    image(imgbk, 0, 0, width, height);
    PFont myFont;
    myFont = loadFont("Rockwell-ExtraBold-65.vlw");
    textFont(myFont);
    fill(255);
    text("Start", 80, 400);
  }
}

void mousePressed() {
  running = !running;

```

_PS : `EOF` means end of file, and it’s because with an additional bracket, the parser thought it was the end of the file but there is an else!_
