So now I have completely changed my idea to a much simpler and easier idea. This idea did take me a lot of time to write out and find sources that would help me create it! Also I have learn't a lot of new things in processing like how to use classes and creating your on functions which is very helpful.
This idea I have created is that you have a couple of balls bouncing around the screen and when you click the balls go red and that means you can hit the balls in all directions and when you release the mouse the balls go white and that means you can hit them. meaning that your just watching bouncing balls on a screen. As you click the ellipse doesn't follow right on the mouse it trails behind the mouse so its more of an interactive feature.
My next steps are to learn how to use arrays so I can create hundreds of balls just from changing one number! Also to figure out how to make the balls collide into each other and also how to make the mouse make contact with the balls as well.
Without these, this would be useless. So by the end of the time we have to do this project I will have it completely finished!
HERE IS THE CODE SO FAR:
float A = 35;
float ellipsex = 0;
float ellipsey = 0;
Circle myCircle;
Circle myCircle2;
Circle myCircle3;
Circle myCircle4;
void setup() {
size(500, 500);
smooth();
myCircle = new Circle(0, 200);
myCircle2 = new Circle(300, 0);
myCircle3 = new Circle(250, 250);
myCircle4 = new Circle(350, 100);
}
void draw() {
background(0);
if (mousePressed == true) {
ellipse(ellipsex, ellipsey, A, A);
ellipsex = ellipsex + ((mouseX-ellipsex)/20.0);
ellipsey = ellipsey + ((mouseY-ellipsey)/20.0);
}
if (mousePressed == true) {
fill(255, 0, 0);
}
else {
fill(255);
}
myCircle.play();
myCircle2.play();
myCircle3.play();
myCircle4.play();
}
class Circle {
float x = 0;
float y = 0;
float speedX = 3;
float speedY = 0.2;
Circle(float xx, float yy) {
x = xx;
y = yy;
}
void play() {
Thecircle();
movement();
bouncing();
withgravity();
}
void withgravity() {
speedY = speedY + 0.5;
}
void bouncing() {
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 movement() {
x = x + speedX;
y = y + speedY;
}
void Thecircle() {
ellipse(x, y, 20, 20);
}
}
No comments:
Post a Comment