Ball[] balls = new Ball[600]; // An array of 100 Ball objects! String filename = "Christmas"; PShape bot; int sceneNumber = 1; PImage img; import ddf.minim.*; import ddf.minim.effects.*;
Minim minim; AudioPlayer groove;
void setup() { //setup function size(1920, 1080); //set the size of the window bot = loadShape("santa_claus_vector.svg"); smooth(); for (int i = 0; i < balls.length; i ++ ) { // Initialize each Ball using a for loop. balls[i] = new Ball(color (255), random(width), random(height), random(5), random(3), random(10, 25));
} minim = new Minim(this); groove = minim.loadFile("WeWishYouShort.mp3", 2048); }
void draw() { groove.loop(); if (sceneNumber == 1) { background(0, 0, 153); for (int i = 0; i < balls.length; i ++ ) { // Run each Car using a for loop. balls[i].displayAndMove(); }
translate(width/5, height/5); float zoom = map(mouseX, 0, width, 0.1, 4.5); scale(zoom); shape(bot, mouseX, mouseY); } for(int i = 0; i < groove.bufferSize() - 1; i++) { line(i, 50 + groove.left.get(i)50, i+1, 50 + groove.left.get(i+1)50); line(i, 150 + groove.right.get(i)50, i+1, 150 + groove.right.get(i+1)50); }
if (sceneNumber == 2) {
img = loadImage("xmas card.0.jpg");
image(img, 0, 0, 1440, 810);}
}
void mousePressed() {
textSize(60);
//stroke(0, 0, 0);
fill(255, 0, 0);
text("Marry Christmas", 550, 170);
text("Happy New Year", 550, 250);
}
class Ball { //define a new class called Ball color c; //define a color variable called c float xpos; float ypos; float xspeed; float yspeed; float diam;
Ball(color tempC, float tempxpos, float tempypos, float tempxspeed, float tempyspeed, float tempdiam) { //this is the constructor for the class c = tempC; //set the color value to be the color passed in from the attribute xpos = tempxpos; ypos = tempypos; xspeed = tempxspeed; yspeed = tempyspeed; diam = tempdiam; }
void displayAndMove() { noStroke(); fill(c); //set the fill value to the value of the colour variable ellipse(xpos, ypos, diam, diam); //define the ellipse: (x, y, width, height) xpos = xpos+xspeed; //move the ball in x ypos = ypos+yspeed; //move the ball in y if (xpos > width) { //detect the right and left edges of the screen xpos = 0; } if (ypos > height) { //detect the bottom and top edges of the screen ypos = 0; }
} //end of the displayAndMove function
} //end of the class definition
void keyPressed() { if ( key == '2' ) sceneNumber = 2; if ( key == '1' ) sceneNumber = 1; if ( key == 'p' ) sceneNumber = 2; { int d = day(); int m = month(); int h = hour(); int min= minute(); int s = second();
String days = String.valueOf(d);
String month = String.valueOf(m);
String hours = String.valueOf(h);
String minutes = String.valueOf(min);
String seconds = String.valueOf(s);
println(filename +"-" + days + "-" + month + "-"+ hours + "-"+ minutes+ "-" + seconds + ".jpg");
save(filename+ "-"+ days +"-" + month + "-"+ hours + "-" + minutes+"-" + seconds + ".jpg");
delay(1000);
background(255);
}
}