From 73c1083c8f406c18e9859f982f376575ad73113f Mon Sep 17 00:00:00 2001 From: ewang803 Date: Tue, 1 Dec 2015 13:10:01 -0500 Subject: [PATCH 1/6] Blue square, circle, duck --- VoidFunctions/VoidFunctions.pde | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..30d0c6b 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,69 @@ +PVector loc, vel; +void setup() { + size(800, 600); + + loc = new PVector (width/3, height/2); + vel = new PVector (random(10), random (10)); + loc.add(vel); +} + +void draw() { + background(0); + drawABlueSquare(); + drawACircle(); + if (mousePressed) { + drawADuck(); + } +} + +void drawABlueSquare() { + fill(180, 203, 207, 60); + rect(width/2, height/2, 50, 50); +} + +void drawACircle() { + fill(random(255), mouseY, mouseX, 70); + ellipse(mouseX, mouseY, 30, 30); +} + +void drawADuck() { + loc.add(vel); + //Body + fill(235, 235, 0); + stroke(240, 230, 140); + ellipse(loc.x, loc.y, 50, 50); + arc(loc.x+50, loc.y+20, 70, 75, 0, PI); + + stroke(0, 0, 0); + arc(loc.x+50, loc.y+35, 25, 20, 0, PI); + + //Legs & mouth + stroke(255, 162, 0); + strokeWeight(2); + line(loc.x+48, loc.y+58, loc.x+43, loc.y+70); + line(loc.x+58, loc.y+58, loc.x+66, loc.y+70); + triangle(loc.x+36, loc.y+74, loc.x+43, loc.y+70, loc.x+46, loc.y+77); + triangle(loc.x+64, loc.y+77, loc.x+66, loc.y+70, loc.x+73, loc.y+74); + triangle(loc.x-20, loc.y+15, loc.x-35, loc.y+10, loc.x-25, loc.y); + + //Eye + fill(0, 0, 0); + noStroke(); + ellipse(loc.x-7, loc.y-3, 5, 5); + + //Movement + if (loc.x>= width) { + vel.x = -abs(vel.x); //if the ball hits the right wall, assign x velocity the negative version of itself + } else if (loc.x <= 0) { + vel.x = abs(vel.x); //if the ball hits the left wall, assign x velocity the positive version of itself + } + if (loc.y >= height) { + vel.y = -abs(vel.y); //if the ball hits the right wall, assign x velocity the negative version of itself + } else if (loc.y <= 0) { + vel.y = abs(vel.y); //if the ball hits the left wall, assign x velocity the positive version of itself + } +} + + +//dataType name(parameters) {block of code} \ No newline at end of file From 8b2263b6fe029224aebe81a0890cba448ffaa20a Mon Sep 17 00:00:00 2001 From: ewang803 Date: Tue, 1 Dec 2015 13:11:22 -0500 Subject: [PATCH 2/6] Color for blue square updated --- VoidFunctions/VoidFunctions.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 30d0c6b..46a115e 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -18,7 +18,7 @@ void draw() { } void drawABlueSquare() { - fill(180, 203, 207, 60); + fill(5, 227, 255, 80); rect(width/2, height/2, 50, 50); } From 60d24fd79a50ed942c19ec179ed0d9c7212f1499 Mon Sep 17 00:00:00 2001 From: ewang803 Date: Tue, 1 Dec 2015 13:12:58 -0500 Subject: [PATCH 3/6] Little edits --- VoidFunctions/VoidFunctions.pde | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 46a115e..6e5ab3b 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -54,14 +54,14 @@ void drawADuck() { //Movement if (loc.x>= width) { - vel.x = -abs(vel.x); //if the ball hits the right wall, assign x velocity the negative version of itself + vel.x = -abs(vel.x); } else if (loc.x <= 0) { - vel.x = abs(vel.x); //if the ball hits the left wall, assign x velocity the positive version of itself + vel.x = abs(vel.x); } if (loc.y >= height) { - vel.y = -abs(vel.y); //if the ball hits the right wall, assign x velocity the negative version of itself + vel.y = -abs(vel.y); } else if (loc.y <= 0) { - vel.y = abs(vel.y); //if the ball hits the left wall, assign x velocity the positive version of itself + vel.y = abs(vel.y); } } From 06f3585e4c0ebbf82d3565ba7e8d54e30ec3afb9 Mon Sep 17 00:00:00 2001 From: ewang803 Date: Thu, 3 Dec 2015 13:14:44 -0500 Subject: [PATCH 4/6] Fnihsed --- ReturningValues/ReturningValues.pde | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..cc3da6f 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,40 @@ +//Declare variables +float x, y, varx, vary, timer; +boolean trigger = false; //sets when a certain +void setup () { + background(0); + size(800, 600); +} + +void draw () { + if (trigger == false) { + String answer = drawATriangle(); + textSize(20); + fill(random(255), random(255), random(255)); + text(answer, 50, 35); + } + timer+=1; + if (timer >= 100) { + timer = 0; + trigger = false; + background(0); + } +} + +String drawATriangle() { + float x = 50; + float y = 50; + float varx = random(550); + float vary = random(400); + fill(random(255), random(255), random(255)); + triangle(x, y, x, y+vary, x+varx, y+vary); + trigger = true; + return calculateHyp(varx, vary); +} + +String calculateHyp(float varx, float vary) { + float hyp = sqrt(sq(varx) + sq(vary)); + String s = "The length of the hypotenuse is " + hyp; + return s; +} \ No newline at end of file From daf21d64d84349b7dc60a5c77c1ce9eacebfa152 Mon Sep 17 00:00:00 2001 From: ewang803 Date: Thu, 3 Dec 2015 13:23:07 -0500 Subject: [PATCH 5/6] Complete --- ReturningValues/ReturningValues.pde | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..d10c3d7 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,40 @@ +//Declare variables +float x, y, varx, vary, timer; +boolean trigger = false; +void setup () { + background(0); + size(800, 600); +} + +void draw () { + if (trigger == false) { + String answer = drawATriangle(); + textSize(20); + fill(random(255), random(255), random(255)); + text(answer, 50, 35); + } + timer+=1; + if (timer >= 100) { + timer = 0; + trigger = false; + background(0); + } +} + +String drawATriangle() { + float x = 50; + float y = 50; + float varx = random(550); + float vary = random(400); + fill(random(255), random(255), random(255)); + triangle(x, y, x, y+vary, x+varx, y+vary); + trigger = true; + return calculateHyp(varx, vary); +} + +String calculateHyp(float varx, float vary) { + float hyp = sqrt(sq(varx) + sq(vary)); + String s = "The length of the hypotenuse is " + hyp; + return s; +} \ No newline at end of file From a69b4ae827ad75c2cc360bc9a9c02f16b9797fd1 Mon Sep 17 00:00:00 2001 From: ewang803 Date: Mon, 7 Dec 2015 12:28:59 -0500 Subject: [PATCH 6/6] Final --- ReturningValues/ReturningValues.pde | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 912c8ae..7b69384 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1,10 +1,7 @@ //Declare variables float x, y, varx, vary, timer; -<<<<<<< HEAD boolean trigger = false; //sets when a certain -======= -boolean trigger = false; ->>>>>>> refs/remotes/origin/returning-functions + void setup () { background(0);