Tiffany - K(alternate)

By Tiffany
//Click and hold the mouse to bring the balloons together Balloon big; Balloon small; PImage balloon; PImage ball1; PImage ball2; float w = 0.9; float h = 1.2; void setup () { size (400, 400); smooth(); balloon = loadImage ("balloon.png"); ball2 = loadImage("balloon1.png"); ball1 = loadImage("balloon2.png"); big = new Balloon(ball1, 150, PI, 0.5, 35); small = new Balloon (ball2, 70, PI/16, 1.1, 60); } void draw () { background(58, 134, 203); fill(40,0,0); big.display(); big.move(); small.display(); small.move(); } class Balloon { float x = width/2; float y = height/2; float targetX; float targetY; float tilta; float tiltb; float a; float c; float s; float h; float w; float easing = 0.03; int direction = -1; Balloon (PImage ball, float bWidth, float bAngle, float bSpeed, float bColor) { w = bWidth; a = bAngle; s = bSpeed; c = bColor; h = w*1.2; } //end class balloon void move () { tilta = cos (a)/32; tiltb = sin(a)/6; a +=0.1; } // end void move; void display(){ if (mousePressed == true) { targetX = mouseX; targetY = mouseY; x += (targetX -x) * easing; y += (targetY -y) * easing; } stroke(0); noFill(); pushMatrix(); translate(x, y); rotate(tilta); image(ball1, -w/2, -h, w, h); rotate(tiltb); fill(144, 74, 0); rect (-w/13, w/25, w/5, w/7); popMatrix(); y += s; x += s/3 * direction; x = constrain(x, 0, 400); if (y > (height+h/2)) { x+= random (-50,50); y = -w; // w *= random(0.5, 2); } if ((x > width + w/2) || (x < w/2)) { direction = -direction; } } //end void display; } //end class Balloon

One Comment

  1. Posted November 5, 2008 at 1:50 pm | Permalink

    Very nice motion! They feel light and floating. It’s a shame they disappear off the bottom of the screen.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*