Delayed interation with an object
in
Programming Questions
•
2 years ago
I am trying to write a program that remembers the past mouseX and mouseY values that the user inputs for a defined number of milliseconds in order to create a trail of objects behind the mouse's current position. I have this code so far that has no such function, but renders a rotating cube that follows the mouse:
Sorry if my description was not coherent, I am a beginner to computer programming. It is also very possible that I am overlooking a very simple solution to my problem. Thank you in advance for your help. :)
- import processing.opengl.*;
Cube cube1;
float angleCounter = 0.0;
float angleSteps = 300.0;
void setup(){
size(500, 500, OPENGL);
frameRate(60);
smooth();
cube1 = new Cube(100, #FFAAAA); //Size, color (hex)
}
void draw() {
angleCounter += TWO_PI/angleSteps;
background(#FFFFFF);
cube1.display();
} - class Cube {
int cubeSize;
int cubeColor;
int frames;
Cube(int tmpCubeSize, int tmpCubeColor) {
cubeSize = tmpCubeSize;
cubeColor = tmpCubeColor;
}
void display(){
translate(mouseX, mouseY);
rotateX(angleCounter);
rotateY(2*angleCounter);
fill(cubeColor);
box(cubeSize);
}
}
Sorry if my description was not coherent, I am a beginner to computer programming. It is also very possible that I am overlooking a very simple solution to my problem. Thank you in advance for your help. :)
1
