class/objects for novice
in
Programming Questions
•
2 years ago
hi I recently started learning processing..
I'm having some trouble making my program run
Could anyone tell me how I would make it run properly..basically trying to generate a randomly colored circle that follows the mouse.
thanks in advance.
I'm having some trouble making my program run
Could anyone tell me how I would make it run properly..basically trying to generate a randomly colored circle that follows the mouse.
thanks in advance.
- void setup(){
size(200,200);
myCreation = new Creation();
}
class Creation {
colour r;
int xpos;
int ypos;
Creation() {
r = random(colour(255));
xpos = mouseX;
ypos = mouseY;
}
void display() {
fill(r);
ellipse(xpos, ypos, 20, 10);
}
}
//end class
//making and using class
Creation myCreation; //declare variable to hold creation object
void start() {
myCreation = new Creation(); //make new creation object
}
void draw() {
myCreation.display();
}
1