Unexpected token: void

boolean running = false;
PImage imgbk;
PImage imgm;
PImage albert;
PImage imgnote;
PImage[] img = new PImage[2];
int totalNum = 4;
int dx, dy;
int score;
int startTime;
int albertX, albertY, albertW, albertH;
int darwinX, darwinY, darwin

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

imgbk = loadImage(“b.jpg”);
imgm = loadImage(“m.jpg”);
imgnote = loadImage(“n.png”);
albert = loadImage(“a.jpg”);

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;

for (int i =0; i < img.length; i=i+1)
{
img[i] = loadImage(“albert” + i + “.jpg”);
}
}

void draw() {
fill(0);
if (running) {
image(imgm, 0, 0, width, height);
image(imgnote, mouseX, mouseY, 100, 130);

for (int i = 0; i < img.length; i=i+1)
{
  image(albert[i], albertX, albertY, albertW, albertH);
}

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;
}

Not sure what’s wrong with my code T T

Hello,

It is not formatted correctly for the forum which makes it difficult to read and copy:
https://discourse.processing.org/faq#format-your-code

:)

boolean running = false;
PImage imgbk;
PImage imgm;
PImage albert;
PImage imgnote;
PImage[] img = new PImage[2];
int totalNum = 4;
int dx, dy;
int score;
int startTime;
int albertX, albertY, albertW, albertH;
int darwinX, darwinY, darwin

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

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

  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;

  for ( int i = 0; i < img.length; i=i+1 )
  {
    img[i] = loadImage("albert" + i + ".jpg");
  }
}


void draw() {
  fill(0);
  if (running) {
    image(imgm, 0, 0, width, height);
    image(imgnote, mouseX, mouseY, 100, 130);

    for (int i = 0; i < img.length; i=i+1)
    {
      image(albert[i], albertX, albertY, albertW, albertH);
    }

    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;
}

Hello,

Something is missing in the line before setup():

int darwinX, darwinY, darwin

:)

1 Like