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 › Sketch is not compiling, shows no bugs
Page Index Toggle Pages: 1
Sketch is not compiling, shows no bugs (Read 531 times)
Sketch is not compiling, shows no bugs
Dec 13th, 2009, 6:56pm
 
Hi,

I'm having a strange problem with the following code. When I try to run it, the program window doesn't show up. However, a little java applet icon shows up in my dock (I'm on a mac), and I'm also not receiving any errors.

Other sketches are working fine, so it's got to be a problem with this specific code, but I'm not sure how to begin debugging something like this, where the window doesn't even open!

Any ideas? Thanks!! Smiley

- David

------------------------------

color redC = color(255, 0, 0);
color purple  = color(170, 23, 193);
color yellow = color(255, 255, 0);
color blueC = color(50, 50, 255);
color orange = color(255, 128, 0);
color greenC = color(14, 193, 2);
color pink = color(250, 154, 212);

color p1Color = pink;
color p2Color = pink;
color recentColor = pink;

int p1Pos = 0; // player 1 position
int p2Pos = 0; // player 2 position
int timeSize = 375;
int nowSize = 1;

boolean p1Turn = true; // keeps track of whose turn it is
boolean gameOver = false; // keeps track of if the game is still going
boolean showMenu = true;

void setup(){
 size(800, 400);
 colorMode(HSB, 360, 100, 100);
}

void draw(){
 background(0, 0, 99);
 
 if(p1Pos >= 300){
   gameOver = true;
 } else if(p2Pos >= 300){
   gameOver = true;
 }
 
 stroke(0, 0, 60);
 fill(0, 0, 99);
 
 rectMode(CORNER);
 // left slider pole
 rect(100, 50, 10, 300);
 // right slider pole
 rect(690, 50, 10, 300);
 
 rectMode(CENTER);
 // player 1
 fill(p1Color);
 rect(105, 350 - p1Pos, 30, 30);
 // player 2
 fill(p2Color);
 rect(695, 350 - p2Pos, 30, 30);
 
 // time-keeper boundary
 noFill();
 rect(width/2, height/2, timeSize, timeSize);
 
 // time-keeper grower
 fill(recentColor);
 rect(width/2, height/2, nowSize, nowSize);
 if(gameOver == false){
   nowSize+=2;
 }
 
 // turn-keeper arrows
 fill(65, 35, 99);
 if(p1Turn == true){
   triangle(55, 350 - p1Pos, 45, (350-p1Pos)+10, 45, (350-p1Pos)-10);
 } else if(p1Turn == false){
   triangle(745, 350 - p2Pos, 755, (350-p2Pos)+10, 755, (350-p2Pos)-10);
 }
 
}

void keyPressed(){
 if(gameOver == true){
   start();
 } else {
   if(key == 'q' || key == 'Q'){
     if(p1Turn == true){
       if(p1Pos <= 300){
         int move = int(random(2, 16));
         p1Pos = p1Pos + move;
         p1Turn = false;
         nowSize = 0;
       }
     }
   }
   if(key == 'p' || key == 'P'){
     if(p1Turn == false){
       if(p2Pos <= 300){
         int move = int(random(2, 16));
         p2Pos = p2Pos + move;
         p1Turn = true;
         nowSize = 0;
       }
     }
   }
   if(key == BACKSPACE){
     start();
   }
 }
}

// function to reset the game (go to the "menu")
void reset(){
 showMenu = true;
 p1Color = pink;
 p2Color = pink;
 recentColor = pink;
 p1Pos = 0;
 p2Pos = 0;
 timeSize = 375;
 nowSize = 1;
}

// function to start the game
void start(){
 showMenu = false;
 gameOver = false;
}
Re: Sketch is not compiling, shows no bugs
Reply #1 - Dec 13th, 2009, 7:17pm
 
never mind. I just figured it out. I had a function named "start()", which must not be allowed!
Page Index Toggle Pages: 1