We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Missing Right parenthesis
Page Index Toggle Pages: 1
Missing Right parenthesis (Read 1055 times)
Missing Right parenthesis
Dec 4th, 2009, 2:12pm
 
My program doesn't run... It points that there might be a missing right parenthesis at the 86th line(HIT TEST). Maybe I've stuffed too much conditions inside the if()?

Here's the code:

int tamanho;
int[] timer = new int[3];

boolean startGame;
boolean pauseGame;
boolean endGame;

SPACE zone;
AVATAR player;
MINION[] enemies = new MINION[1];

void setup()
{
 tamanho = 400;

 startGame = false;
 pauseGame = false;
 endGame = false;
 
 size(tamanho,tamanho);
 frameRate(30);
 
 zone = new SPACE (loadImage("figura1.png"), loadImage("figura2.png"), loadImage("figura3.png"),
 color(27,214,219), (tamanho/2), (tamanho/2), (tamanho/15), (tamanho/15));
 
 player = new AVATAR (color(31,155,16), (tamanho/2), (tamanho/2),
 (tamanho/15), (tamanho/15),(tamanho/80), (tamanho/40));
 
 /*for(int i = 0; i < enemies.length; i++)
 {
   enemies[i] = new MINION (color(193,12,12), (tamanho/15), (tamanho/15), (tamanho/80), (tamanho/80));
 }*/
}

void draw()
{
 background(color(#141B5D));
 smooth();
 zone.display();

 if(endGame == false)
 {
   player.display();
 
   if(startGame == true)
   {
     zone.alphaPhase = true;
     player.move();
     timer[timer.length]++;
     
     //TIMER
     if(timer[timer.length] > 9)
     {
       timer[timer.length - 1]++;
       timer[timer.length] = 0;
       
       if(timer[timer.length - 1] > 9)
       {
         timer[timer.length - 2]++;
         timer[timer.length - 1] = 0;
         
         if(timer[timer.length - 2] > 9)
         {
           timer[timer.length - 3]++;
           timer[timer.length - 2] = 0;
           
           if(timer[timer.length - 3] > 9)
           {
             for(int i = 0; i <= timer.length; i++)
             {
               timer[i] = 9;
             }
           }
         }
       }
     }
             
     
     for(int i = 0; i < enemies.length; i++)
     {
       enemies[i].display();
       enemies[i].move();
     }
     
     //HIT TEST
     for(int i = 0; i < enemies.length; i++)
     {
       if (enemies[i].xpos + enemies[i].xsize / 2 >= player.xpos - player.xsize * 0,4 &&
           enemies[i].xpos + enemies[i].xsize / 2 <= player.xpos + player.xsize * 0,4 &&
           enemies[i].ypos + enemies[i].ysize / 2 >= player.ypos - player.ysize * 0,2 &&
           enemies[i].ypos + enemies[i].ysize / 2 <= player.ypos + player.ysize * 0,2
           ||
           enemies[i].xpos - enemies[i].xsize / 2 >= player.xpos - player.xsize * 0,4 &&
           enemies[i].xpos - enemies[i].xsize / 2 <= player.xpos + player.xsize * 0,4 &&
           enemies[i].ypos - enemies[i].ysize / 2 >= player.ypos - player.ysize * 0,2 &&
           enemies[i].ypos - enemies[i].ysize / 2 <= player.ypos + player.ysize * 0,2
           ||
           enemies[i].xpos + enemies[i].xsize / 2 >= player.xpos - player.xsize * 0,2 &&
           enemies[i].xpos + enemies[i].xsize / 2 <= player.xpos + player.xsize * 0,2 &&
           enemies[i].ypos + enemies[i].ysize / 2 >= player.ypos - player.ysize * 0,4 &&
           enemies[i].ypos + enemies[i].ysize / 2 <= player.ypos + player.ysize * 0,4
           ||
           enemies[i].xpos - enemies[i].xsize / 2 >= player.xpos - player.xsize * 0,2 &&
           enemies[i].xpos - enemies[i].xsize / 2 <= player.xpos + player.xsize * 0,2 &&
           enemies[i].ypos - enemies[i].ysize / 2 >= player.ypos - player.ysize * 0,4 &&
           enemies[i].ypos - enemies[i].ysize / 2 <= player.ypos + player.ysize * 0,4)
           {
             endgame = true;
           }
     }
     
     if(timer % 150 == 0)
     {
       MINION enemy = new MINION (color(193,12,12), (tamanho/15), (tamanho/15), (tamanho/80),
       (tamanho/80));
       
       enemies = (MINION[]) append(enemies,enemy);
     }
   }
   
   if(startGame == false && pauseGame == true)
   {
     zone.pause();
   }

   if(endGame == true)
   {
     player.endGame();
     zone.endGame();
     zone.alphaPhase = true;
     MINION[] enemies = (MINION[] enemies) subset();
     println("Score:" + timer);    
   }
 }
}

void mousePressed()
{
   startGame =! startGame;
   pauseGame = true;
   
   if(endgame == true)
   {
     endgame == false;
   }
}

Thanks in advance.
Re: Missing Right parenthesis
Reply #1 - Dec 4th, 2009, 2:43pm
 
Guilherme.  Vous êtes français?  Just a hunch, but maybe you're too used to using commas to denote decimal points:

Quote:
enemies[i].xpos + enemies[i].xsize / 2 >= player.xpos - player.xsize * 0,4


That doesn't make a lot of sense.  Perhaps it should be 0.4?  Sadly I've had to get used to wrong spellings on words like 'colour' and I think you might need to get used to points for decimal places Wink
Re: Missing Right parenthesis
Reply #2 - Dec 8th, 2009, 10:58am
 
I'm Brazilian blindfish, thanks for the help. It worked! But it seems that my program still full of bugs... I'm trying to use a variable from one class in another. Both are public classes, why it isn't working?
Re: Missing Right parenthesis
Reply #3 - Dec 8th, 2009, 11:30am
 
Ah - sorry; I shouldn't make assumptions based on personal experiences:  I just remembered that French people use commas to separate decimals, but obviously they're not the only ones...

OK - If I fix the commas the next error I see is this:

Code:
MINION[] enemies = (MINION[] enemies) subset(); 



You're trying to cast it as an array of minions so you shouldn't repeat the variable name in the cast:

Code:
MINION[] enemies = (MINION[]) subset(); 



After that I get a missing class (SPACE) error - not surprising as you haven't posted the code for those Wink

BTW - missing right parentheses errors needn't be caused on the tab the interpreter displays with the error.  The tabs are there for convenience, but you should think of everything as one long piece of code - a missing parenthesis on one tab will affect the other tabs.  

One other suggestion: test constantly, especially when you're starting out.  Unless you're 100% confident you haven't done something that might break your programme then run it to check.  That way you catch the errors as you make them rather than having to debug lots accumulated errors.
Page Index Toggle Pages: 1