Programming noob, help with simple program
in
Programming Questions
•
11 months ago
Okay so this:
http://www.ic.ucsc.edu/~ptantalo/cmps5J/Fall12/Examples/BallBounce/ is what the program I'm trying to write is supposed to do.
This is what I have so far:
// ball variables
float X, Y, Xspeed, Yspeed;
// environment variables
float gravity, stopSpeed, dissipation;
void setup() {
size(500,500);
smooth();
// initialize ball variables
X=250;
Y=50;
Xspeed=0;
Yspeed=0;
// initialize physical variables
gravity=0.6;
stopSpeed=0.2;
dissipation=0.08;
}
// do not change this function
void draw() {
background(0,255,255);
displayBall();
if( mousePressed && mouseOnBall() ){
holdBall();
}else{
moveBall();
updateSpeed();
}
}
void displayBall(){
fill(255, 0, 0);
ellipse(X, Y, 100, 100);
}
void holdBall(){
fill(255,0, 0);
ellipse(mouseX, mouseY, 100, 100);
}
void moveBall(){
Y += Yspeed;
X += Xspeed;
}
void updateSpeed(){
if( abs(speed)<stopSpeed ){
speed=0.0;
}else if (y>height-50){
speed = -(1-dissipation);
}
boolean mouseOnBall(float d, 50){
float d = dist(X, Y, mouseX, mouseY);
return d<50;
}
I get an unexpected token: boolean when I try to run it. Can someone tell me what I'm doing wrong? I am super new to programming so I'm sure there's a lot wrong with it. Any help is much appreciated!
1