Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
wfeldman
wfeldman'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
I am trying to make a ball bounce with an exponential function just like gravity.
[3 Replies]
09-Feb-2012 01:50 PM
Forum:
Programming Questions
Except after my first loop the ball goes off screen. here's my code:
int x=0;
int dir;
boolean flag=true;
void setup() {
background(0);
size(400, 400);
frameRate(10);
}
void draw() {
background(0);
fill(64, 63, 160);
ellipse(200, 50+pow(x, 2), 60, 60);
fill(22, 99, 8);
rect(-1, 345, 401, 55);//
x=x+dir;
if (50+pow(x, 2)<315 && flag) {
dir=1;
flag=false ;
}
if (50+pow(x, 2)>315) {
dir=-1;
}
if (50+pow(x, 2)<3)
flag=true;
if (50+pow(x, 2)>3)
flag=false;
}
Any suggestions
«Prev
Next »
Moderate user : wfeldman
Forum