diff --git a/.DS_Store b/.DS_Store index 7cdfdf7..b0e4967 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/StudentFolders/.DS_Store b/StudentFolders/.DS_Store new file mode 100644 index 0000000..cae0291 Binary files /dev/null and b/StudentFolders/.DS_Store differ diff --git a/StudentFolders/A3/.DS_Store b/StudentFolders/A3/.DS_Store new file mode 100644 index 0000000..f10a9c8 Binary files /dev/null and b/StudentFolders/A3/.DS_Store differ diff --git a/StudentFolders/A3/AaronH/.DS_Store b/StudentFolders/A3/AaronH/.DS_Store new file mode 100644 index 0000000..fefbf65 Binary files /dev/null and b/StudentFolders/A3/AaronH/.DS_Store differ diff --git a/StudentFolders/A3/AaronH/FINALIE_DRAFT PROJECT/FINALIE_PROJECT.pde b/StudentFolders/A3/AaronH/FINALIE_DRAFT PROJECT/FINALIE_PROJECT.pde new file mode 100644 index 0000000..506920b --- /dev/null +++ b/StudentFolders/A3/AaronH/FINALIE_DRAFT PROJECT/FINALIE_PROJECT.pde @@ -0,0 +1,60 @@ + +boolean task1Done = false; +boolean task2Done = false; +boolean task3Done = false; + +void setup() { + size(800, 600); + textAlign(CENTER, CENTER); + textSize(16); +} + +void draw() { + background(245); + + textSize(28); + fill(0); + text("TASKLY", width/2, 50); + + fill(task1Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 150, 80, 80); + fill(0); + text("Task 1", 150, 150); + + fill(task2Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 280, 80, 80); + fill(0); + text("Task 2", 150, 280); + + fill(task3Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 410, 80, 80); + fill(0); + text("Task 3", 150, 410); + + + + // pets + fill(255, 220, 180); + ellipse(500, 250, 150, 150); + fill(0); + text("Your Pet", 500, 250); + + // spinny w.heel + fill(255, 255, 180); + ellipse(650, 450, 120, 120); + fill(0); + text("Spin", 650, 450); +} + +void mousePressed() { + + if (dist(mouseX, mouseY, 150, 150) < 40) { + task1Done = !task1Done; + } + if (dist(mouseX, mouseY, 150, 280) < 40) { + task2Done = !task2Done; + } + if (dist(mouseX, mouseY, 150, 410) < 40) { + task3Done = !task3Done; + } +} diff --git a/StudentFolders/A3/AaronH/Programming Proposal .pdf b/StudentFolders/A3/AaronH/Programming Proposal .pdf new file mode 100644 index 0000000..0c00090 Binary files /dev/null and b/StudentFolders/A3/AaronH/Programming Proposal .pdf differ diff --git a/StudentFolders/A3/AaronH/Taskly_Final_Project/Taskly_Final_Project.pde b/StudentFolders/A3/AaronH/Taskly_Final_Project/Taskly_Final_Project.pde new file mode 100644 index 0000000..47b0319 --- /dev/null +++ b/StudentFolders/A3/AaronH/Taskly_Final_Project/Taskly_Final_Project.pde @@ -0,0 +1,204 @@ +boolean task1Done = false; +boolean task2Done = false; +boolean task3Done = false; +int petSize = 150; +int points = 0; + +boolean spinning = false; +float rotamt = 0; +float rotateby = 0; +String message = ""; +color petColor; + +void setup() { + size(800, 600); + textAlign(CENTER, CENTER); + textSize(16); + loadProgress(); +} + +void draw() { + background(245); + textSize(28); + fill(0); + text("TASKLY", width/2, 50); + + textSize(18); + fill(50); + text("Points: " + points, width/2, 90); + + fill(task1Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 150, 80, 80); + fill(0); + text("Task 1", 150, 150); + + fill(task2Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 280, 80, 80); + fill(0); + text("Task 2", 150, 280); + + fill(task3Done ? color(150, 255, 150) : color(200, 220, 255)); + ellipse(150, 410, 80, 80); + fill(0); + text("Task 3", 150, 410); + + if (points < 30) { + petColor = color(255, 220, 180); + } else if (points < 70) { + petColor = color(180, 255, 180); + } else { + petColor = color(180, 200, 255); + } + + fill(petColor); + ellipse(500, 250, petSize, petSize); + fill(0); + text("Your Pet", 500, 180); + fill(0); + ellipse(480, 240, 10, 10); + ellipse(520, 240, 10, 10); + + if (points < 70) { + noFill(); + stroke(0); + arc(500, 265, 40, 20, 0, PI); + } else { + fill(0); + arc(500, 270, 40, 20, PI, TWO_PI); + } + + pushMatrix(); + translate(650, 450); + rotate(radians(rotamt)); + + for (int i = 0; i < 10; i++) { + if (i % 2 == 0) { + fill(255); + } else { + fill(0); + } + arc(0, 0, 200, 200, i * TWO_PI / 10, (i + 1) * TWO_PI / 10, PIE); + } + + circle(0, -100, 10); + fill(255, 0, 0); + textSize(20); + + for (int i = 0; i < 10; i++) { + text(i, 0, -70); + rotate(TWO_PI/10); + } + + popMatrix(); + fill(255, 0, 0); + triangle(650 - 10, 450 - 110, 650 + 10, 450 - 110, 650, 450 - 80); + + fill(0); + text("Spin", 650, 450); + + fill(255, 100, 100); + rect(700, 20, 80, 30, 10); + fill(0); + textSize(16); + text("Restart", 740, 35); + + if (message != "") { + fill(0, 150, 0); + textSize(18); + text(message, width/2, 550); + } + + if (spinning) { + rotamt += rotateby; + rotateby *= 0.98; + + if (rotamt > 360) { + rotamt -= 360; + } + + if (abs(rotateby) < 0.1) { + spinning = false; + rotateby = 0; + + float angle = rotamt - 15; + if(angle < 0){ + angle += 360; + } + + int slice = int(map(angle, 360, 0, 0, 10)); + + boolean isWhite = (slice % 2 == 1); + int gained = isWhite ? int(random(30, 80)) : int(random(10, 40)); + + points += gained; + message = (isWhite ? "White!" : "Black!") + " +" + gained + " Points!"; + saveProgress(); + } + } +} + +void mousePressed() { + if (dist(mouseX, mouseY, 150, 150) < 40) { + task1Done = !task1Done; + petSize += task1Done ? 10 : -10; + points += task1Done ? 10 : -10; + saveProgress(); + } + + if (dist(mouseX, mouseY, 150, 280) < 40) { + task2Done = !task2Done; + petSize += task2Done ? 10 : -10; + points += task2Done ? 10 : -10; + saveProgress(); + } + + if (dist(mouseX, mouseY, 150, 410) < 40) { + task3Done = !task3Done; + petSize += task3Done ? 10 : -10; + points += task3Done ? 10 : -10; + saveProgress(); + } + + if (dist(mouseX, mouseY, 650, 450) < 80 && !spinning) { + spinning = true; + rotateby = 10; + message = ""; + } + + if (mouseX > 700 && mouseX < 780 && mouseY > 20 && mouseY < 50) { + resetProgress(); + } +} + +void saveProgress() { + String[] data = { + str(points), + str(petSize), + str(task1Done), + str(task2Done), + str(task3Done) + }; + saveStrings("save.txt", data); +} + +void resetProgress() { + points = 0; + petSize = 150; + task1Done = false; + task2Done = false; + task3Done = false; + message = "Progress Reset!"; + saveProgress(); +} + +void loadProgress() { + java.io.File file = new java.io.File(sketchPath("save.txt")); + if (!file.exists()) return; + + String[] data = loadStrings("save.txt"); + points = int(data[0]); + petSize = int(data[1]); + task1Done = data[2].equals("true"); + task2Done = data[3].equals("true"); + task3Done = data[4].equals("true"); +} diff --git a/StudentFolders/A3/AaronH/Taskly_Final_Project/save.txt b/StudentFolders/A3/AaronH/Taskly_Final_Project/save.txt new file mode 100644 index 0000000..3e2831c --- /dev/null +++ b/StudentFolders/A3/AaronH/Taskly_Final_Project/save.txt @@ -0,0 +1,5 @@ +0 +150 +false +false +false diff --git a/StudentFolders/A3/AaronH/badMario/badMario.pde b/StudentFolders/A3/AaronH/badMario/badMario.pde new file mode 100644 index 0000000..3c3f4d7 --- /dev/null +++ b/StudentFolders/A3/AaronH/badMario/badMario.pde @@ -0,0 +1,76 @@ +float rectX = 400; +float rectY = 300; +float rectWidth = 60; +float rectHeight = 40; + +float gravity = 0.6; +float velocity = 0; +boolean isJumping = false; + +float moveSpeed = 5; +boolean onBox = false; + +import java.util.HashSet; +HashSet keysDown = new HashSet(); + +Box b1, b2; + +void setup() { + size(800, 600); + b1 = new Box(500, 400, 100, 100); + b2 = new Box(300, 250, 100, 100); +} + +void draw() { + background(200); + + // Draw boxes + b1.drawBox(); + b2.drawBox(); + + customPress(); + + // Apply gravity + velocity += gravity; + rectY += velocity; + + // Check landing on boxes + boxstuff(b1, b2); + + // Floor collision + if (rectY + rectHeight > height) { + rectY = height - rectHeight; + velocity = 0; + isJumping = false; + onBox = true; + } + + // Draw player + fill(255, 0, 0); + rect(rectX, rectY, rectWidth, rectHeight); +} + +void customPress() { + for (Integer k : keysDown) { + if (k == 87) { // W + if (!isJumping) { + velocity = -20; // jump power + isJumping = true; + } + } + if (k == 68) { // D + rectX += moveSpeed; + } + if (k == 65) { // A + rectX -= moveSpeed; + } + } +} + +void keyPressed(KeyEvent e) { + keysDown.add(e.getKeyCode()); +} + +void keyReleased(KeyEvent e) { + keysDown.remove(e.getKeyCode()); +} diff --git a/StudentFolders/A3/AaronH/badMario/box.pde b/StudentFolders/A3/AaronH/badMario/box.pde new file mode 100644 index 0000000..34852cd --- /dev/null +++ b/StudentFolders/A3/AaronH/badMario/box.pde @@ -0,0 +1,47 @@ +class Box { + float bx, by, bw, bh; + + Box(float x, float y, float w, float h) { + bx = x; + by = y; + bw = w; + bh = h; + } + + void drawBox() { + fill(255); + rect(bx, by, bw, bh); + } + + void stopPlayer() { + boolean touching = rectRect(rectX, rectY, rectWidth, rectHeight, bx, by, bw, bh); + + // Land on top + if (touching && rectY + rectHeight <= by + 10 && velocity >= 0 && + rectX + rectWidth > bx && rectX < bx + bw) { + rectY = by - rectHeight; + velocity = 0; + isJumping = false; + onBox = true; + } + // Hitting sides + else if (touching && rectY + rectHeight > by && rectY < by + bh) { + if (rectX + rectWidth > bx && rectX < bx) { + rectX = bx - rectWidth; // left side + } else if (rectX < bx + bw && rectX + rectWidth > bx + bw) { + rectX = bx + bw; // right side + } + } + // Hitting bottom + else if (touching && rectY < by + bh && velocity < 0 && + rectX + rectWidth > bx && rectX < bx + bw) { + rectY = by + bh; + velocity = 0.5; + } + + // Reset onBox only if not standing on top + if (!(rectY + rectHeight == by)) { + onBox = false; + } + } +} diff --git a/StudentFolders/A3/AaronH/badMario/boxstuff.pde b/StudentFolders/A3/AaronH/badMario/boxstuff.pde new file mode 100644 index 0000000..e292a8b --- /dev/null +++ b/StudentFolders/A3/AaronH/badMario/boxstuff.pde @@ -0,0 +1,21 @@ +void boxstuff(Box... boxes) { + onBox = false; // reset + + for (Box b : boxes) { + // Check if player is landing on top of the box + if (rectY + rectHeight <= b.by + 10 && + rectY + rectHeight + velocity >= b.by && // will land this frame + rectX + rectWidth > b.bx && rectX < b.bx + b.bw) { + + rectY = b.by - rectHeight; // place on top + velocity = 0; + onBox = true; + isJumping = false; + } + } + + // If not on any box, allow gravity + if (!onBox) { + isJumping = true; + } +} diff --git a/StudentFolders/A3/AaronH/badMario/collisions.pde b/StudentFolders/A3/AaronH/badMario/collisions.pde new file mode 100644 index 0000000..387a3d1 --- /dev/null +++ b/StudentFolders/A3/AaronH/badMario/collisions.pde @@ -0,0 +1,15 @@ +boolean rectRect(float r1x, float r1y, float r1w, float r1h, float r2x, float r2y, float r2w, float r2h) { + return r1x + r1w > r2x && r1x < r2x + r2w && r1y + r1h > r2y && r1y < r2y + r2h; +} + +boolean pointRect(float px, float py, float rx, float ry, float rw, float rh) { + return px >= rx && px <= rx + rw && py >= ry && py <= ry + rh; +} + +boolean pointCircle(float px, float py, float cx, float cy, float cr) { + return dist(px, py, cx, cy) < cr; +} + +boolean circleCircle(float cx1, float cy1, float cr1, float cx2, float cy2, float cr2) { + return dist(cx1, cy1, cx2, cy2) < cr1 + cr2; +} diff --git a/StudentFolders/A3/AaronH/sketch_251021a/sketch_251021a.pde b/StudentFolders/A3/AaronH/sketch_251021a/sketch_251021a.pde new file mode 100644 index 0000000..7f688b5 --- /dev/null +++ b/StudentFolders/A3/AaronH/sketch_251021a/sketch_251021a.pde @@ -0,0 +1,67 @@ +float x = 400; +float y = 575; +float speed = 4; +float bulletX = -10; +float bulletY = -10; +boolean bulletFired = false; + +import java.util.HashSet; +HashSet keysDown = new HashSet(); + +void setup() { + size(800, 600); +} + +void draw() { + background(50); + customPress(); + + + circle(x, y, 50); + + + if (bulletFired) { + bulletY -= 10; + circle(bulletX, bulletY, 10); + if (bulletY < 0) { + bulletFired = false; + } + } +} + +void customPress() { + if (keysDown.contains(16)) { + speed = 8; + } else { + speed = 4; + } + + if (keysDown.contains(65)) { + x -= speed; + } + if (keysDown.contains(68)) { + x += speed; + } + + if (x < 25) x = 25; + if (x > 775) x = 775; +} + +void keyPressed(KeyEvent e) { + keysDown.add(e.getKeyCode()); + + + if (e.getKeyCode() == 32 && !bulletFired) { + bulletFired = true; + bulletX = x; + bulletY = y - 25; + } +} + +void keyReleased(KeyEvent e) { + keysDown.remove(e.getKeyCode()); +} + +boolean keyDown(int kcode) { + return keysDown.contains(kcode); +} diff --git a/StudentFolders/A3/AaronH/vocab_jesse_pdf/collisions.pde b/StudentFolders/A3/AaronH/vocab_jesse_pdf/collisions.pde deleted file mode 100644 index 15878d9..0000000 --- a/StudentFolders/A3/AaronH/vocab_jesse_pdf/collisions.pde +++ /dev/null @@ -1,170 +0,0 @@ -boolean pointCircle(float px, float py, float cx, float cy, float cr){ - if(dist(px, py, cx, cy) < cr){ - return true; - } else { - return false; - } -} - -boolean circleCircle(float cx1, float cy1, float cr1, float cx2, float cy2, float cr2){ - if(dist(cx1, cy1, cx2, cy2) < cr1 + cr2){ - return true; - } else { - return false; - } -} - -boolean pointRect(float px, float py, float rx, float ry, float rw, float rh) { - - // is the point inside the rectangle's bounds? - if (px >= rx && // right of the left edge AND - px <= rx + rw && // left of the right edge AND - py >= ry && // below the top AND - py <= ry + rh) { // above the bottom - return true; - } - return false; -} - -boolean rectRect(float r1x, float r1y, float r1w, float r1h, float r2x, float r2y, float r2w, float r2h) { - - // are the sides of one rectangle touching the other? - - if (r1x + r1w >= r2x && // r1 right edge past r2 left - r1x <= r2x + r2w && // r1 left edge past r2 right - r1y + r1h >= r2y && // r1 top edge past r2 bottom - r1y <= r2y + r2h) { // r1 bottom edge past r2 top - return true; - } - return false; -} - -// CIRCLE/RECTANGLE -boolean circleRect(float cx, float cy, float radius, float rx, float ry, float rw, float rh) { - - // temporary variables to set edges for testing - float testX = cx; - float testY = cy; - - // which edge is closest? - if (cx < rx) testX = rx; // test left edge - else if (cx > rx+rw) testX = rx+rw; // right edge - if (cy < ry) testY = ry; // top edge - else if (cy > ry+rh) testY = ry+rh; // bottom edge - - // get distance from closest edges - float distX = cx-testX; - float distY = cy-testY; - float distance = sqrt( (distX*distX) + (distY*distY) ); - - // if the distance is less than the radius, collision! - if (distance <= radius) { - return true; - } - return false; -} - -// LINE/POINT -boolean linePoint(float x1, float y1, float x2, float y2, float px, float py) { - - // get distance from the point to the two ends of the line - float d1 = dist(px,py, x1,y1); - float d2 = dist(px,py, x2,y2); - - // get the length of the line - float lineLen = dist(x1,y1, x2,y2); - - // since floats are so minutely accurate, add - // a little buffer zone that will give collision - float buffer = 0.1; // higher # = less accurate - - // if the two distances are equal to the line's - // length, the point is on the line! - // note we use the buffer here to give a range, - // rather than one # - if (d1+d2 >= lineLen-buffer && d1+d2 <= lineLen+buffer) { - return true; - } - return false; -} - -boolean lineCircle(float x1, float y1, float x2, float y2, float cx, float cy, float r) { - - // is either end INSIDE the circle? - // if so, return true immediately - boolean inside1 = pointCircle(x1,y1, cx,cy,r); - boolean inside2 = pointCircle(x2,y2, cx,cy,r); - if (inside1 || inside2) return true; - - // get length of the line - float distX = x1 - x2; - float distY = y1 - y2; - float len = sqrt( (distX*distX) + (distY*distY) ); - - // get dot product of the line and circle - float dot = ( ((cx-x1)*(x2-x1)) + ((cy-y1)*(y2-y1)) ) / pow(len,2); - - // find the closest point on the line - float closestX = x1 + (dot * (x2-x1)); - float closestY = y1 + (dot * (y2-y1)); - - // is this point actually on the line segment? - // if so keep going, but if not, return false - boolean onSegment = linePoint(x1,y1,x2,y2, closestX,closestY); - if (!onSegment) return false; - - // optionally, draw a circle at the closest - // point on the line - //fill(255,0,0); - //noStroke(); - //ellipse(closestX, closestY, 20, 20); - - // get distance to closest point - distX = closestX - cx; - distY = closestY - cy; - float distance = sqrt( (distX*distX) + (distY*distY) ); - - if (distance <= r) { - return true; - } - return false; -} - -// LINE/LINE -boolean lineLine(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { - - // calculate the distance to intersection point - float uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1)); - float uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1)); - - // if uA and uB are between 0-1, lines are colliding - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) { - - // optionally, draw a circle where the lines meet - float intersectionX = x1 + (uA * (x2-x1)); - float intersectionY = y1 + (uA * (y2-y1)); - //fill(255,0,0); - //noStroke(); - //ellipse(intersectionX,intersectionY, 20,20); - - return true; - } - return false; -} - -boolean lineRect(float x1, float y1, float x2, float y2, float rx, float ry, float rw, float rh) { - - // check if the line has hit any of the rectangle's sides - // uses the Line/Line function below - boolean left = lineLine(x1,y1,x2,y2, rx,ry,rx, ry+rh); - boolean right = lineLine(x1,y1,x2,y2, rx+rw,ry, rx+rw,ry+rh); - boolean top = lineLine(x1,y1,x2,y2, rx,ry, rx+rw,ry); - boolean bottom = lineLine(x1,y1,x2,y2, rx,ry+rh, rx+rw,ry+rh); - - // if ANY of the above are true, the line - // has hit the rectangle - if (left || right || top || bottom) { - return true; - } - return false; -} diff --git a/StudentFolders/A3/AaronH/vocab_jesse_pdf/vocab_jesse_pdf.pde b/StudentFolders/A3/AaronH/vocab_jesse_pdf/vocab_jesse_pdf.pde deleted file mode 100644 index 27c1613..0000000 --- a/StudentFolders/A3/AaronH/vocab_jesse_pdf/vocab_jesse_pdf.pde +++ /dev/null @@ -1,36 +0,0 @@ -ArrayList positions = new ArrayList(); -PVector target = new PVector(500, 100); -int score = 0; - -void setup() { - size(800, 600); -} - -void draw() { - background(50); - - for (int i = positions.size() - 1; i >= 0; i--) { - positions.get(i).y -= 5; - circle(positions.get(i).x, positions.get(i).y, 10); - - if (dist(positions.get(i).x, positions.get(i).y, target.x, target.y) < 50) { - score++; - positions.remove(i); - continue; - } - - if (positions.get(i).y < 0) { - positions.remove(i); - } - } - - circle(target.x, target.y, 100); - textSize(40); - fill(255); - text(score, 50, 50); -} - -void mousePressed() { - positions.add(new PVector(mouseX, mouseY)); -} -