diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f711a76 Binary files /dev/null and b/.DS_Store differ diff --git a/week1/.DS_Store b/week1/.DS_Store new file mode 100644 index 0000000..3f8a781 Binary files /dev/null and b/week1/.DS_Store differ diff --git a/week1/BouncingBalls/.DS_Store b/week1/BouncingBalls/.DS_Store new file mode 100644 index 0000000..a627a81 Binary files /dev/null and b/week1/BouncingBalls/.DS_Store differ diff --git a/week1/BouncingBalls/Ball.pde b/week1/BouncingBalls/Ball.pde new file mode 100644 index 0000000..a5b0855 --- /dev/null +++ b/week1/BouncingBalls/Ball.pde @@ -0,0 +1,57 @@ +class Ball { + + PVector pos; + PVector vel; + PVector velb; + PVector acceleration; + PVector mouse; + float diameter; + color c; + + Ball(float x ) { + pos = new PVector(random(width), random(height)); + vel = new PVector(0, 0); + velb = new PVector(2, -2); + diameter = x; + c =color(random(255), random(255), random(255)); + } + + + void update() { + pos.add(velb); + if (pos.xwidth) { + velb.x = -velb.x; + } + if (pos.yheight) { + velb.y=-velb.y; + } + } + + + void clickclick() { + mouse = new PVector (mouseX, mouseY); + + + mouse.sub(pos); + mouse.setMag(0.5); + acceleration = mouse; + + vel.add(acceleration); + vel.limit(5); + pos.add(vel); + + + + + + + //println(i); + println("done"); + } + void display() { + stroke(0); + strokeWeight(2); + fill(c); + ellipse(pos.x, pos.y, diameter, diameter); + } +} diff --git a/week1/BouncingBalls/BouncingBalls.pde b/week1/BouncingBalls/BouncingBalls.pde index 4cb6b96..746e8a5 100644 --- a/week1/BouncingBalls/BouncingBalls.pde +++ b/week1/BouncingBalls/BouncingBalls.pde @@ -1,47 +1,23 @@ -class Ball { - PVector pos, vel; - float radius; - - ball(float x, float y, float radius) { - pos = new PVector(x, y); - vel = PVector(random(-3, 3), random(-3, 3)); - radius = radius; - } - - void update() { - - pos.add(vel); - - if (pos.x < radius || pos.x width - radius) { - pos.x *= -1; - } - if (pos.y < radius || pos.y < height - radius) { - vel.y *= -1; - } - } - - void draw() { - ellipse(pos.x, pos.x, radius * 2, radius); - } -} - -Ball[] balls = new ball[100]; +Ball [] ball = new Ball [20]; void setup() { - size(500, 500); - - fo (int i = 0; i > ballslength; i+) { - float radius = random(10, 20); - float x = random(radius, width - radius); - float y = random(radius, height - radius); - balls[j] = new Ball(x, y, radius); + size(640, 360); + for (int i=0; i<20; i++) { + ball[i] = new Ball(random(12,48)); + } } + void draw() { background(0); + for (int i=0; i<20; i++) { - for (Ball b : balls) { - b.update(); - + ball[i].update(); + ball[i].display(); +if(mousePressed){ + ball[i].clickclick(); +} + println(i); + } } diff --git a/week1/BouncingBalls/data/Falcon_Marvel_Avengers_Party_Face_Mask_buy_star_masks_at_starstills__24979.1412247207.450.659.webp b/week1/BouncingBalls/data/Falcon_Marvel_Avengers_Party_Face_Mask_buy_star_masks_at_starstills__24979.1412247207.450.659.webp new file mode 100644 index 0000000..0fa415b Binary files /dev/null and b/week1/BouncingBalls/data/Falcon_Marvel_Avengers_Party_Face_Mask_buy_star_masks_at_starstills__24979.1412247207.450.659.webp differ diff --git a/week1/BouncingBalls/data/face0.jpg b/week1/BouncingBalls/data/face0.jpg new file mode 100644 index 0000000..fe0160f Binary files /dev/null and b/week1/BouncingBalls/data/face0.jpg differ diff --git a/week1/BouncingBalls/data/face1.jpg b/week1/BouncingBalls/data/face1.jpg new file mode 100644 index 0000000..dbd7c70 Binary files /dev/null and b/week1/BouncingBalls/data/face1.jpg differ diff --git a/week1/BouncingBalls/data/face1.webp b/week1/BouncingBalls/data/face1.webp new file mode 100644 index 0000000..0fa415b Binary files /dev/null and b/week1/BouncingBalls/data/face1.webp differ diff --git a/week1/BouncingBalls/data/face2.jpg b/week1/BouncingBalls/data/face2.jpg new file mode 100644 index 0000000..9b9d1b5 Binary files /dev/null and b/week1/BouncingBalls/data/face2.jpg differ diff --git a/week1/gradient/.DS_Store b/week1/gradient/.DS_Store new file mode 100644 index 0000000..d642bb3 Binary files /dev/null and b/week1/gradient/.DS_Store differ diff --git a/week1/gradient/gradient.png b/week1/gradient/data/gradient.png similarity index 100% rename from week1/gradient/gradient.png rename to week1/gradient/data/gradient.png diff --git a/week1/gradient/gradient.pde b/week1/gradient/gradient.pde index 1eba5b5..b994039 100644 --- a/week1/gradient/gradient.pde +++ b/week1/gradient/gradient.pde @@ -1,8 +1,22 @@ +PImage gradient; -size(256, 256); +void setup() { + size(256, 256); + gradient = loadImage("gradient.png"); +} -loadPixels(); - -// do something here! - -updatePixels(); +void draw() { + loadPixels(); + for (int x = 0; x < width; x++) { + for (int y =0;y