Changing numbers in the text through the use of variables.

I try to put a variable in the text () to have a changing number for the scores{}, but the program debugger gives me an error.

Please help.

float lX; float lY; float lW; float lH; float lS; float rX; float rY; float rW; float rH; float rS; boolean up, down; boolean v1, h1; boolean started = true; int mate = 9; int xPos; int yPos; int incDec =4;
int bVal=0; int gVal=0; int rVal=250; int w = 40; int h = 40; int speedx = 2; int speedy = 3;

void setup(){ //I h8 U Java!!! size (600,600); rectMode (CENTER); ellipseMode (CENTER); lX = 30; lY = height/2; lW = 40; lH=100; lS = 5; rX=570; rY = height/2; rW = 40; rH=100; rS=5; xPos = 250; yPos = 250; }

void draw (){ background(0); drawlpad(); drawrpad(); movelpad(); moverpad(); drawball(); moveball(); restrictpaddle(); contactpad(); contactr(); }

void drawlpad(){ fill(0,250,0); rect(lX,lY,lW,lH); }

void drawrpad(){ fill(0,0,250); rect(rX,rY,rW,rH); }

void movelpad(){ if (up){ lY=lY-lS; } if (down){ lY=lY+lS; } }

void moverpad(){ if(v1){ rY=rY-rS; } if(h1){ rY=rY+lS; } }

void drawball(){
fill(rVal,gVal,bVal); ellipse(xPos,yPos,w,h); //bsize }

void moveball(){ xPos = xPos +incDec;

if (xPos >600-w/2){ incDec=-incDec; setup(); } if (xPos<10+w/2){ incDec=-incDec; setup(); } yPos = yPos + mate; if (yPos>600){ mate=-mate;

} if (yPos < 0){ mate=-mate;

}

}

void restrictpaddle(){ if (lY - lH/2 < 0) { lY = lY + lS; } if (lY + lH/2 > height) { lY= lY - lS; } if (rY - rH/2 < 0) { rY = rY + rS; } if (rY + rH/2 > height) { rY = rY - rS; } }

void contactpad() { if (xPos-w/2 < lX + lW/2 && yPos-h/2 < lY +lH/2 && yPos +lH/2 > lY - lH/2){ if (incDec<0){ incDec = -incDec; } } }

void contactr() { if(xPos+w/2 > rX - rW/2 && yPos-h/2 < rY + rH/2 && yPos+h/2 > rY -rH/2){ if (incDec>0){ incDec = -incDec; } } }

void keyPressed(){ if(started = true){ if (key=='w' || key=='W'){ up=true; } if (key=='s'||key=='S'){ down=true; } if (keyCode==UP){ v1=true; } if(keyCode ==DOWN){ h1=true; } } }

void keyReleased(){ if (key=='w' || key=='W'){ up=false; }

if (key=='s'||key=='S'){ down=false; }

if (keyCode==UP){ v1=false; }

if(keyCode ==DOWN){ h1=false; } }

void mousePressed (){ //for change color int temp; temp=bVal; bVal=gVal; gVal=rVal; rVal=temp; }

/*void scores () { fill(255); text (scorer1, 100, 50); text (scorer, width-100,50); }

Answers

  • Please format your post- edit message, highlight code, press Ctrl-o.

  • the program debugger gives me an error.

    What error? Where?

Sign In or Register to comment.