Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

unexpected token: void error????

$
0
0

Hi,

I've been running into this strange error: unexpected token: void. I've been double checking my code to a previous version of the code that was working properly, and there is very little change, and none of those changes should be causing a problem.

For some reason, processing is highlighting this function when it displays the error message:

    void checkBoundaryCollision ()
    {
      int i = 0;

      if (position.x+(cue.rad/2)+border_width>width)
      {
       velocity_cue.x*=-1;
       i=1;
      }
      else if (position.y+(cue.rad/2)+border_width>height)
      {
        velocity_cue.y*=-1;
        i=1;
      }
      else if (position.x-(cue.rad/2)-border_width<0)
      {
       velocity_cue.x*=-1;
       i=1;
      }
      else if (position.y-(cue.rad/2)-border_width<0)
      {
       velocity_cue.y*=-1;
       i=1;
      }
      if(i!=0)
      {
       ball_wall_collision.play();
       ball_wall_collision.rewind();
      }
    }

And in case it is required for further troubleshooting, this is my loop and setup function:

 void setup ()
    {
      minim = new Minim(this);
      cue_stick_hit = minim.loadSnippet("stick_cue_hit.wav");
      ball_wall_collision = minim.loadSnippet("ball_wall_collision.wav");
      game_over=minim.loadSnippet("game_over.wav");
      background_music = minim.loadSnippet("background_music.wav");
      //mono = loadFont("EdwardianScriptITC48.vlw");
      size(900, 600);//size of processing display window
      frameRate(60); //Sets refresh rate of processing window
      cue.rad = 31.0;//diameter
      cue.col = #e2e9f0;//colour of cue ball


    }

    void draw ()
    {


     if(menu_condition)
      {
        table ();
        menu();
        cue();
        if(mousePressed)
        {
         menu_condition = false;
         //cue_in_pocket = false;
        }
      }
       else if(pause)
        {
        table();
        cue();
        pause();
        textSize(40);
        fill(255);
        text("PAUSED",width/2.5,height/2);
        }

      else
      {
      table();
      cue();
      stick();
      position.add(velocity_cue);
     checkBoundaryCollision();
     velocity_cue.mult(friction_factor);
     velocity_check();
     cue_in_pocket = pocket();
     pause();



     if(cue_in_pocket)
     {
      text("GAME OVER",width/2.75,height/2);
      game_over.play();
      game_over.rewind();
     }
     textSize(14);
     fill(text_color_r,text_color_g,text_color_b);
     text("POWER:"+power_percentage+"%", 100,100);
      }
    }

It doesn't make any sense to me because this is very similar code to a working version, which had the exact same function and was not giving this error at the time... I checked my brackets and that isn't the problem... Is there a specific problem to which this error message points to?

Thanks!


Viewing all articles
Browse latest Browse all 2896

Trending Articles