Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
willtownsend
willtownsend's Profile
1
Posts
4
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 the xspeed, and yspeed random, please help.
[8 Replies]
29-Aug-2013 04:59 PM
Forum:
Programming Questions
int x;
int xspeed;
int y;
int yspeed;
void setup(){
size(500,500);
x=25;
y=250;
}
void draw() {
int r=random (-2,2);
yspeed=r;
xspeed=r;
if(x > width-25){
xspeed = xspeed*(-1);
}
if(x < width-475){
xspeed = xspeed *(-1);
}
if(y > height-25){
yspeed = yspeed *(-1);
}
if(y <height-475){
yspeed = yspeed *(-1);
}
x = x+xspeed;
y = y+yspeed;
background(255);
fill(#AA7DFE);
stroke(#0EE31A);
ellipse(x,y, 50,50);
}
«Prev
Next »
Moderate user : willtownsend
Forum