Unexpected token:void


#1

here is my code:

float xcoord;
float ycoord;
float npoints;
float xdivider;
float ydivider;


void setup () {
     size (600,600);
     npoints=12;
     xdivider=width/(npoints+1);
     ydivider=height/(npoints+1);
     smooth();
     
  
  }
  
  void draw (){
     background (51);
     xcoord=xdivider;
     ycoord=ydivider;
     
     for (int j=0;j<npoints;j++)
     {
       for (int i=0;i<npoints;i++)
       {
     
  star(xcoord,ycoord);

  xcoord=xcoord+xdivider;
  
  }
  xcoord=xdivider;
  ycoord=ycoord+ydivider;
  
  }
  
  
  
  void star (float x, float y)
{
  
   pushMatrix();
     translate (x,y);
     fill(127);
     stroke(255);
     strokeWeight(2);
     //vertices of the star
     beginShape ();
     vertex(x,y-50);
     vertex(x+14,y-20);
     vertex(x+47,y-15);
     vertex(x+23,y+7);
     vertex(x+29,y+40);
     vertex(x,y+25);
     vertex(x-29,y+40);
     vertex(x-23,y+7);
     vertex(x-47,y-15);
     vertex(x-14,y-20);
     endShape (CLOSE);
     
     popMatrix();
  
  }

when i try to play it, it ids not working because al the line void star (float x, float y) it says unexpected token:void

what can i do?

many thanks


#2

Hi @sissib make sure you use the pre-formatted code button “</>”

And from looking at your code, it looks like you’re missing a curly brace at the end of your for Loop.:slight_smile: