Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
naushad1290
naushad1290's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Hey guys help me on collision detection
[1 Reply]
21-Jun-2013 10:50 AM
Forum:
Programming Questions
hey guys in this code i want to make a bouncing ball but the ball is not bouncing...........so tell me whats wrong with it
float xPos = width/2;
float yPos = height/2;
int xDirection = 1;
int yDirection = 1;
float xSpeed = 2.2;
float ySpeed = 1.8;
int ballRed = 60;
float pRect;
void setup(){
size(600,300);
smooth();
frameRate(60);
//noCursor();
}
void draw(){
noStroke();
fill(#64F7E2);
rect(0,0,width/2,height);
fill(#4DB2A3);
rect(width/2,0,width/2,height);
fill(#4DB2A3);
pRect = getPRect();
rect(20,pRect,10,40);
ellipseMode(RADIUS);
updateBall();
fill(0);
ellipse(xPos,yPos,ballRed,ballRed);
}
float getPRect(){
if(mouseY<=height-38){
return mouseY;
}
else
return height-38;
}
void updateBall(){
xPos += xSpeed*xDirection;
yPos += ySpeed*yDirection;
if(xPos>width-ballRed || xPos<ballRed){
xDirection *= -1;
}
if(yPos>height-ballRed || yPos<ballRed){
yDirection *= -1;
}
}
«Prev
Next »
Moderate user : naushad1290
Forum