Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
chey.rogers142
chey.rogers142's Profile
2
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
Beginner - Making objects bounce off a cursor
[1 Reply]
24-Apr-2011 06:33 PM
Forum:
Programming Questions
hi I am very new to processing and I am unsure of how to make objects bounce off the cursor but using no clicking. How do i do this?
how do i make an object fall from the very top of the screen and keep repeating it randomly?
[2 Replies]
24-Apr-2011 05:17 PM
Forum:
Programming Questions
See i am trying to make balloons fall from the top of the screen but they keep appearing in the middle of the screen instead. How do I fix this
//DECLARE
Balloon[] balloonCollection = new Balloon[50];
void setup() {
size(500,500);
smooth();
//INTIALIZE
for( int i = 0; i < balloonCollection.length; i++){
balloonCollection[i] = new Balloon(random(0,width),random(0,200));
}
}
void draw(){
background(255);
//CALL FUNCTIONALITY
for( int i = 0; i < balloonCollection.length; i++){
balloonCollection[i].run();
}
}
class Balloon{
//GLOBAL VARIABLES
float x = 0;
float y = 0;
float speedX = 2;
float speedY = 2;
//CONSTRUCTOR
Balloon(float _x ,float _y) {
x = _x;
y = _y;
}
//FUNCTIONS
void run() {
display();
move();
bounce();
gravity();
mouseMoved();
}
void gravity(){
speedY += 0.2;
}
void bounce(){
if(x > width){
speedX = speedX * -1;
}
if(x < 0){
speedX = speedX * -1;
}
if(y > height) {
speedY = speedY * -1;
}
if(y < 0){
speedY = speedY * -1;
}
}
void move(){
x +=speedX;
y += speedY;
}
void display() {
fill(255,0,0);
ellipse(x,y,60,60);
line(x,y+30,x,y+100);
}
}
«Prev
Next »
Moderate user : chey.rogers142
Forum