Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int maxBalls=90;
- float[] x = new float[maxBalls];
- float[] y = new float[maxBalls];
- float[] xPlus = new float[maxBalls];
- float[] yPlus = new float[maxBalls];
- boolean spawn=false;
- boolean repeat=true;
- int click=0;
- int count=0;
- void setup() {
- //fullScreen();
- size(700, 500);
- }
- void draw() {
- background(#FFFFFF);
- fill(#000000);
- ball();
- text("FPS: " + frameRate, 1, 10);
- text("Balls: " + click, 1, 20);
- if (click==maxBalls) {
- repeat=false;
- }
- }
- void mousePressed() {
- if (repeat) {
- spawn=true;
- x[click] = mouseX;
- y[click] = mouseY;
- xPlus[click]=random(-10, 10);
- yPlus[click]=random(-10, 10);
- click++;
- }
- }
- void ball() {
- if (spawn) {
- ellipse(x[count], y[count], 30, 30);
- x[count]=x[count]+xPlus[count];
- y[count]=y[count]+yPlus[count];
- }
- if (x[count]<=15 || x[count]>=width-15) {
- xPlus[count]=xPlus[count]*(-1);
- }
- if (y[count]<=15 || y[count]>=height-15) {
- yPlus[count]=yPlus[count]*(-1);
- }
- count++;
- if (count>=click) {
- count=0;
- } else {
- ball();
- }
- }
- void keyPressed() {
- if (key=='r') {
- click=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement