From d20c820b2f42195d287a06468355d04f975d95cb Mon Sep 17 00:00:00 2001 From: mccuen1 <50152124+mccuen1@users.noreply.github.com> Date: Tue, 7 May 2019 14:40:47 -0500 Subject: [PATCH] Add files via upload --- tracktd/Stage.pde | 83 ++++++++++++++++++++++++++++++ tracktd/UI.pde | 32 ++++++++++++ tracktd/onScreen.pde | 44 ++++++++++++++++ tracktd/pengies.pde | 114 +++++++++++++++++++++++++++++++++++++++++ tracktd/puffles.pde | 78 ++++++++++++++++++++++++++++ tracktd/trackTiles.pde | 50 ++++++++++++++++++ tracktd/tracktd.pde | 66 ++++++++++++++++++++++++ 7 files changed, 467 insertions(+) create mode 100644 tracktd/Stage.pde create mode 100644 tracktd/UI.pde create mode 100644 tracktd/onScreen.pde create mode 100644 tracktd/pengies.pde create mode 100644 tracktd/puffles.pde create mode 100644 tracktd/trackTiles.pde create mode 100644 tracktd/tracktd.pde diff --git a/tracktd/Stage.pde b/tracktd/Stage.pde new file mode 100644 index 0000000..86efbf4 --- /dev/null +++ b/tracktd/Stage.pde @@ -0,0 +1,83 @@ +class Stage { + + boolean show[][] = { {false, false, false, false, false, false, false, true, false, false, false, false }, + { false, true, true, true, true, false, false, true, false, false, false ,false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, true, true, true, true, true, true, true, true, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, true, true, true, false }, + { false, false, false, false, true, false, false, false, false, false, false, false } }; + +boolean pengCells[][] = { {false, false, false, false, false, false, false, true, false, false, false, false }, + { false, true, true, true, true, false, false, true, false, false, false ,false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, false, false, true, false, false, true, false ,false ,false, false }, + { false, true, true, true, true, true, true, true, true, true, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, false, false, true, false }, + { false, false, false, false, true, false, false, true, true, true, true, false }, + { false, false, false, false, true, false, false, false, false, false, false, false } }; + + Stage() { + + } + + +void display() { + for (int i=0; i<13; i++) { + for (int j=0; j<12; j++) { + highlightGreen(i, j); + if ((show[i][j] == false)) { + cells[i][j].display(); + } + } + } +} + +int getCellX(float cellX) { + int mapX = int(map(cellX, 200, 850, 0, 13)); + int consX = constrain(mapX, 0, 13); + return consX; //always needs to return int +} + +int getCellY(float cellY) { + int mapY = int(map(cellY, 0, 650, 0, 13)); + return mapY; +} + +void highlightGreen(int x, int y) { + if (mouseX > 200) { //restriction to making the fill + if (getCellX(mouseX) == x && getCellY(mouseY) == y) { //IMPORTANT CODE STRUCTURE FOR CHECKING ALL CELLS + cells[x][y].cFill = color(24, 189, 28, 125); + } else { //refills when i and j do not match + cells[x][y].cFill = color(225, 240, 247); + } + } else { //refills when moves off the screen + cells[x][y].cFill = color(225, 240, 247); + } +} + +void highlightRed(int x, int y) { + if (mouseX > 200) { //restriction to making the fill + if (getCellX(mouseX) == x && getCellY(mouseY) == y) { //IMPORTANT CODE STRUCTURE FOR CHECKING ALL CELLS + cells[x][y].cFill = color(206, 19, 20, 25); + } else { //refills when i and j do not match + cells[x][y].cFill = color(225, 240, 247); + + // cells[x][y].cFill = color(225, 240, 247); } + } + }else { //refills when moves off the screen + cells[x][y].cFill = color(225, 240, 247); +} +} +} diff --git a/tracktd/UI.pde b/tracktd/UI.pde new file mode 100644 index 0000000..17db3a4 --- /dev/null +++ b/tracktd/UI.pde @@ -0,0 +1,32 @@ +class Interface { + float opt1X = 75, opt1Y = 75; + Penguin pI = new Penguin(opt1X, opt1Y); + + Interface() { + + } + + void display() { // the left-most choosing ui thing + noStroke(); + fill(80); + rect(100, height/2, 200, height); + + displayTowers(); // displays the tower options + } + + void displayTowers() { + stroke(240); + strokeWeight(3); + fill(200, 140); + ellipse(opt1X, opt1Y, 60, 60); // surrounding circle + + pI.display(); + } + + void displayUpgrades() { + + } + + + +} diff --git a/tracktd/onScreen.pde b/tracktd/onScreen.pde new file mode 100644 index 0000000..57a25fc --- /dev/null +++ b/tracktd/onScreen.pde @@ -0,0 +1,44 @@ + +int pengCount = 0; +int pengCountC; +Penguin pengs[] = new Penguin[10]; + +void showTowers() { +pengCountC = constrain(pengCount, 0, 10); +int pengCellX = 0; +int pengCellY = 0; + for (int i = 0; i < pengCountC; i++) { + pengs[i].display(); + + + if (mousePressed) { + pengCellX = track.getCellX(mouseX); + pengCellY = track.getCellY(mouseY); + println(track.pengCells[track.getCellX(mouseX)][track.getCellY(mouseY)]); //something doesnt work + if (track.show[pengCellX][pengCellY] == false // check for if its track + && track.pengCells[track.getCellX(mouseX)][track.getCellY(mouseY)] == false) { //check to see if spot is ocupied //checks for penguin on mouse + pengs[i].setStay(true); + + } + + } + if (!pengs[i].stay) { // only moves to place when the boolean is false + pengs[i].update(); + } + + } + for (int i = 0; i < pengCount; i++) { + if (pengs[i].inside()){ // add the check for other penguins + track.pengCells[pengCellX][pengCellY] = true; + } else { + track.pengCells[pengCellX][pengCellY] = false; + } + } +} + +void mousePressed() { //mousePress function to not stack events +pengCountC = constrain(pengCount, 0, 10); + if (mouseX < 200) { // change to UI.pI.inside(); + pengCount += 1; + } +} diff --git a/tracktd/pengies.pde b/tracktd/pengies.pde new file mode 100644 index 0000000..161ed50 --- /dev/null +++ b/tracktd/pengies.pde @@ -0,0 +1,114 @@ +class Penguin{ + float pengx; + float pengy; + float armrx; + float armlx; + float army; + boolean stay = false; + + //float pengCellX[] = new float[13]; + // float peng + + Penguin(float tx, float ty){ + pengx = tx; + pengy = ty; + armrx = pengx + 20; + armlx = pengx - 20; + army = pengy - 5; + } + + float getX(){ + return pengx; + } + + float getY(){ + return pengy; + } + + void setX(float tx){ + pengx = tx; + armrx = pengx + 20; + armlx = pengx - 20; + + } + + void setY(float ty){ + pengy = ty; + army = pengy - 5; + } + + void display(){ + fill(0); + strokeWeight(1); + stroke(255); + ellipse(pengx, pengy, 40, 30); //body + + beginShape(); + vertex(armlx, army); + vertex(armlx - 8, army + 5); + vertex(armlx - 12, army + 18); + vertex(armlx - 5, army + 10); + vertex(armlx, army + 8); + endShape(); + + beginShape(); + vertex(armrx, army); + vertex(armrx + 8, army + 5); + vertex(armrx + 12, army + 18); + vertex(armrx + 5, army + 10); + vertex(armrx + 1, army + 8); + endShape(); + + fill(255, 146, 3); + beginShape(); //beak2 + vertex(pengx - 5, pengy + 15); + vertex(pengx - 5, pengy + 20); + bezierVertex(pengx - 5, pengy + 20, pengx, pengy + 30, pengx + 5, pengy + 20); + vertex(pengx + 5, pengy + 15); + endShape(); + + fill(255); + ellipse(pengx - 7, pengy + 10, 8, 5); //eyes + ellipse(pengx + 7, pengy + 10, 8, 5); + + fill(0); + ellipse(pengx - 7, pengy + 11, 4, 5); + ellipse(pengx + 7, pengy + 11, 4, 5); + } + + void update() { //NEW + pengx = (track.getCellX(mouseX)*50)+225; + pengy = (track.getCellY(mouseY)*50)+25; + armrx = pengx + 20; + armlx = pengx - 20; + army = pengy - 5; + } + //void detectPuff(){ + // for(Puffle p: puffle){ + // p.check(); + // } + //} + + void setStay(boolean set) { //pass in t + if (mouseX > 200) { //extra to not interfere with ui + + if (set) { //core of the code + stay = true; + + } else { + stay = false; + } + } + + } + + boolean inside(){ + float d = dist(pengx, pengy, mouseX, mouseY); + if(d <= 35){ + return true; + } else{ + return false; + } + } + +} // end of class diff --git a/tracktd/puffles.pde b/tracktd/puffles.pde new file mode 100644 index 0000000..337d06c --- /dev/null +++ b/tracktd/puffles.pde @@ -0,0 +1,78 @@ +class Puffle { + + float x, y, xspeed, yspeed; + float xPos[] = { 275, 275, 525, 525, 775, 775, 0 }; + float yPos[] = { 225, 75, 75, 525, 525, 375, 0 }; + int moves[] = { 3, 1, 4, 1, 3, 2 }; + int posOrder_ = 0; // needs to constrain + int posOrder; // actual count value for x and y positions of the track + float r, offset; + float s; // making the speed work off of the radius + + Puffle() { + x = width + 50; + y = 225; + posOrder = constrain(posOrder_, 0, 5); + s = 2.8; + offset = 3; + moveLeft(); + } + +void display() { + fill(0, 235, 0); + stroke(0); + strokeWeight(1); + ellipse(x, y, 40, 40); +} + +void update() { + x += xspeed; + y += yspeed; + println(xspeed); +} + +void moveRight() { // 1 + xspeed = s; + yspeed = 0; +} +void moveLeft() { // 2 + xspeed = -s; + yspeed = 0; +} +void moveUp() { // 3 + xspeed = 0; + yspeed = -s; +} +void moveDown() { // 4 + xspeed = 0; + yspeed = s; +} + +void followTrack() { + update(); + + + if ( (x >= xPos[posOrder] - r && x <= xPos[posOrder] + r) + && (y >= yPos[posOrder] - r && y <= yPos[posOrder] + r) ) { + + if (moves[posOrder] == 1) { + moveRight(); + posOrder ++; + } else if (moves[posOrder] == 2) { + moveLeft(); + posOrder ++; + } else if (moves[posOrder] == 3) { + moveUp(); + posOrder ++; + } else if (moves[posOrder] == 4) { + moveDown(); + posOrder ++; + } + + } + + + +} + +} diff --git a/tracktd/trackTiles.pde b/tracktd/trackTiles.pde new file mode 100644 index 0000000..aa768e0 --- /dev/null +++ b/tracktd/trackTiles.pde @@ -0,0 +1,50 @@ + +class Cell { + float x, y; + color cFill = color(225, 240, 247); + color cStroke = color(175, 190, 193); + + Cell(float x_, float y_) { + x = x_; + y = y_; + } + + void display() { + pushMatrix(); + translate(x, y); + strokeWeight(3); + stroke(cStroke); + fill(cFill); + rect(0, 0, 50, 50); + popMatrix(); + } + + void vertical() { // vertical lanes of ice + pushMatrix(); + translate(x, y); + + strokeWeight(6); + noStroke(); + fill(11, 225, 225, 100); + rect(0, 0, 50, 50); + stroke(255); + line(-25, -25, -25, 25); + line(25, -25, 25, 25); + popMatrix(); + } + void horizontal() { + pushMatrix(); + translate(x, y); + + strokeWeight(6); + noStroke(); + fill(11, 225, 225, 100); + rect(0, 0, 50, 50); + stroke(255); + line(-25, -25, 25, -25); + line(25, 25, -25, 25); + popMatrix(); + } + + +} diff --git a/tracktd/tracktd.pde b/tracktd/tracktd.pde new file mode 100644 index 0000000..37bb1c7 --- /dev/null +++ b/tracktd/tracktd.pde @@ -0,0 +1,66 @@ +Cell cells[][] = new Cell[13][12]; +Stage track = new Stage(); +Penguin peng = new Penguin(0, 0); +Interface UI = new Interface(); +Puffle puffle; + +void setup() { + rectMode(CENTER); + size(850, 600); + puffle = new Puffle(); + + + for (int i=0; i<13; i++) { + for (int j=0; j<12; j++) { + + cells[i][j] = new Cell(i*50+225, j*50+25); + } + } + + for (int i = 0; i < 10; i++) { + pengs[i] = new Penguin(0, 0); + } +} + +void draw() { + background(200); + track.display(); + showTowers(); + // peng.display(); + // peng.update(); + + cells[1][2].vertical(); cells[2][1].horizontal(); + cells[1][3].vertical(); cells[3][1].horizontal(); + cells[6][2].vertical(); cells[4][1].horizontal(); + cells[6][3].vertical(); cells[5][1].horizontal(); + cells[6][5].vertical(); cells[2][4].horizontal(); + cells[6][6].vertical(); cells[3][4].horizontal(); + cells[6][8].vertical(); cells[4][4].horizontal(); + cells[6][9].vertical(); cells[5][4].horizontal(); + cells[11][8].vertical(); cells[7][4].horizontal(); + cells[11][9].vertical(); cells[8][4].horizontal(); + cells[9][4].horizontal(); + cells[10][4].horizontal(); + cells[11][4].horizontal(); + cells[12][4].horizontal(); + cells[0][7].horizontal(); + cells[1][7].horizontal(); + cells[2][7].horizontal(); + cells[3][7].horizontal(); + cells[4][7].horizontal(); + cells[5][7].horizontal(); + cells[7][7].horizontal(); + cells[8][7].horizontal(); + cells[9][7].horizontal(); + cells[10][7].horizontal(); + cells[7][10].horizontal(); + cells[8][10].horizontal(); + cells[9][10].horizontal(); + cells[10][10].horizontal(); + // puffle.display(); +// puffle.update(); + //puffle.followTrack(); + UI.display(); + // println(track.getCellX(mouseX)); + // println(track.getCellY(mouseY)); +}