Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions CPTD_TrackTest/CPTD_TrackTest.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Cell cells[][] = new Cell[13][12];
Stage track = new Stage();
Interface UI = new Interface();
Puffle puffle[] = new Puffle[10];
Penguin peng[] = new Penguin[10];
color blue = color(50, 50, 255);
color red = color(255, 25, 25);
color pink = color(255, 150, 150);

void setup() {
rectMode(CENTER);
size(850, 600);
for (int i = 0; i < puffle.length; i++) {
puffle[i] = 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 < peng.length; i++) {
peng[i] = new Penguin(0, 0);
}
}

void draw() {
background(200);
track.display();
puffle[0].display();
puffle[0].followTrack();

showTowers();
for (int i = 0; i < peng.length; i++) {
peng[i].display();
peng[i].update();
peng[i].calculateSlope();
}

//cells[1][2].vertical();
//cells[1][3].vertical();
//cells[6][2].vertical();
//cells[6][3].vertical();
//cells[6][5].vertical();
//cells[6][6].vertical();
//cells[6][8].vertical();
//cells[6][9].vertical();
//cells[11][8].vertical();
//cells[11][9].vertic);

// puffle.update();

UI.display();
// println(track.getCellX(mouseX));
// println(track.getCellY(mouseY));
}
27 changes: 27 additions & 0 deletions CPTD_TrackTest/Interface.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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() {
}
}
128 changes: 128 additions & 0 deletions CPTD_TrackTest/Penguin.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
class Penguin {
float pengx, pengy, armrx, armlx, army, slopeX[], slopeY[], slopeXConstrain[], slopeYConstrain[];
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;

slopeX = new float[puffle.length];
slopeY = new float[puffle.length];
slopeXConstrain = new float[puffle.length];
slopeYConstrain = new float[puffle.length];
}

void calculateSlope() {
for (int i = 0; i < puffle.length; i++) {
slopeX[i] = 0.05 * (puffle[i].getX() - pengx);
slopeXConstrain[i] = constrain(slopeX[i], -6, 6);

slopeY[i] = 0.05 * (puffle[i].getY() - pengy);
slopeYConstrain[i] = constrain(slopeY[i], -6, 6);
}
}

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;
}

//float getSlopeXConstrain(int k) {
// return slopeXConstrain[k];
//}
//float getSlopeYConstrain(int k) {
// return slopeYConstrain[k];
//}

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;
}
}
}
29 changes: 29 additions & 0 deletions CPTD_TrackTest/Projectile.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Projectile {
float x = 0;
float y = 0;

Projectile(float tx, float ty) {
x = tx;
y = ty;
}

void move(float moveX, float moveY) {
x = x + moveX;
y = y + moveY;
}

float getX() {
return x;
}
float getY() {
return y;
}

void setX(float tx) {
x = tx;
}

void setY(float ty) {
y = ty;
}
}
45 changes: 45 additions & 0 deletions CPTD_TrackTest/SWORDS.PDE
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Sword {

float x, y;

Sword(float tx, float ty) {
x = tx;
y = ty;
}

void display() {
pushMatrix();

translate(width/2 + x, height/2 + y);
rotate(0.003*PI* millis());
rectMode(CENTER);
stroke(140);
fill(220);

rect(0, 0, 5, 60, 4);
fill(139, 69, 19);
rect(0, 42, 6.5, 35);

popMatrix();
}

void move(float moveX, float moveY) {
x = x + moveX;
y = y + moveY;
}

float getX() {
return x;
}
float getY() {
return y;
}

void setX(float tx) {
x = tx;
}

void setY(float ty) {
y = ty;
}
}
82 changes: 82 additions & 0 deletions CPTD_TrackTest/Stage.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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);
}
}
}
Loading