PImage zombieImage;
PImage zombieBanner;
Table lineTable;
int rowCount;
Table deathTable;
Table typeData;
void mouseClicked() {
if(typeData == lineTable) {
typeData = deathTable;
}
}
void setup()
{
background(0);
size(700, 437);
zombieImage = loadImage("zombie.gif");
zombieBanner = loadImage("banner.gif");
lineTable = new Table("Ammo.tsv");
deathTable = new Table("Death.tsv");
typeData = lineTable;
rowCount = typeData.getRowCount();
}
void draw()
{
image(zombieImage, 0, 0);
image(zombieBanner, 190, 10);
PFont leagend2 = loadFont("Andalus-25.vlw");
textFont(leagend2);
fill(#006600); //green
textAlign(LEFT);
textMode(SCREEN);
text("UAT", 640, 120);
text("MSU", 640, 170);
text("UCD", 640, 220);
text("USF", 640, 270);
text("WKU", 640, 320);
text("UNL", 640, 370);
fill(#990000, 100); //red opaque
text("UAT", 642, 122);
text("MSU", 642, 172);
text("UCD", 642, 222);
text("USF", 642, 272);
text("WKU", 642, 322);
text("UNL", 642, 372);
strokeWeight(4);
stroke(#CC0000); //red
line(640, 125, 685, 125);
stroke(#0000CC); //blue
line(640, 175, 685, 175);
stroke(#00FF00); //green
line(640, 225, 685, 225);
stroke(#FFFF00); //yellow
line(640, 275, 685, 275);
stroke(#CC00CC); //pink
line(640, 325, 685, 325);
stroke(#FF9933); //orange
line(640, 375, 685, 375);
PFont leagend = loadFont("OCRAExtended-20.vlw");
textFont(leagend);
textAlign(CENTER);
fill(#006600); //green
text("Day 1", 110, 400);
text("Day 2", 220, 400);
text("Day 3", 330, 400);
text("Day 4", 440, 400);
text("Day 5", 550, 400);
fill(#990000, 100); //red opaque
text("Day 1", 112, 402);
text("Day 2", 222, 402);
text("Day 3", 332, 402);
text("Day 4", 442, 402);
text("Day 5", 552, 402);
stroke (200);
strokeWeight(2);
line(100, 380, 560, 380);
line(100, 100, 100, 380);
line(560, 100, 560, 380);
strokeWeight(1);
line(110, 100, 110, 380);
line(220, 100, 220, 380);
line(330, 100, 330, 380);
line(440, 100, 440, 380);
line(550, 100, 550, 380);
PFont chart = loadFont("OCRAExtended-17.vlw");
textFont(chart);
for (int row = 0; row < rowCount; row++) {
float college = typeData.getFloat(row, 1);
float x1 = typeData.getFloat(row, 2);
float x2 = typeData.getFloat(row, 3);
float x3 = typeData.getFloat(row, 4);
float x4 = typeData.getFloat(row, 5);
float x5 = typeData.getFloat(row, 6);
float g = typeData.getFloat(row, 7);
float gn = typeData.getFloat(row, 7);
drawData(380-x1, 380-x2, 380-x3, 380-x4, 380-x5, 380-g, gn, college);
}
}
void drawData(float x1, float x2, float x3, float x4, float x5, float g, float gn, float college) {
strokeWeight(1);
stroke(200, 100);
line (100, g, 560, g);
fill(#006600); //green
textAlign(LEFT);
text("" + gn + "", 565, g);
fill(#990000, 100); //red opaque
text("" + gn + "", 567, g+2);
if (college == 1) {
stroke(#CC0000); //red
}
if (college == 2) {
stroke(#0000CC); //blue
}
if (college == 3) {
stroke(#00FF00); //green
}
if (college == 4) {
stroke(#FFFF00); //yellow
}
if (college == 5) {
stroke(#CC00CC); //pink
}
if (college == 6) {
stroke(#FF9933); //orange
}
strokeWeight (3);
line (110, x1, 220, x2);
line (220, x2, 330, x3);
line (330, x3, 440, x4);
line (440, x4, 550, x5);
}
// Book code
class Table {
String[][] data;
int rowCount;
Table() {
data = new String[10][10];
}
Table(String filename) {
String[] rows = loadStrings(filename);
data = new String[rows.length][];
for (int i = 0; i < rows.length; i++) {
if (trim(rows[i]).length() == 0) {
continue; // skip empty rows
}
if (rows[i].startsWith("#")) {
continue; // skip comment lines
}
// split the row on the tabs
String[] pieces = split(rows[i], TAB);
// copy to the table array
data[rowCount] = pieces;
rowCount++;
// this could be done in one fell swoop via:
//data[rowCount++] = split(rows[i], TAB);
}
// resize the 'data' array as necessary
data = (String[][]) subset(data, 0, rowCount);
}
int getRowCount() {
return rowCount;
}
// find a row by its name, returns -1 if no row found
int getRowIndex(String name) {
for (int i = 0; i < rowCount; i++) {
if (data[i][0].equals(name)) {
return i;
}
}
println("No row named '" + name + "' was found");
return -1;
}
String getRowName(int row) {
return getString(row, 0);
}
String getString(int rowIndex, int column) {
return data[rowIndex][column]; //here is where the exception was thrown
}
String getString(String rowName, int column) {
return getString(getRowIndex(rowName), column);
}
int getInt(String rowName, int column) {
return parseInt(getString(rowName, column));
}
int getInt(int rowIndex, int column) {
return parseInt(getString(rowIndex, column));
}
float getFloat(String rowName, int column) {
return parseFloat(getString(rowName, column));
}
float getFloat(int rowIndex, int column) {
return parseFloat(getString(rowIndex, column));
}
void setRowName(int row, String what) {
data[row][0] = what;
}
void setString(int rowIndex, int column, String what) {
data[rowIndex][column] = what;
}
void setString(String rowName, int column, String what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = what;
}
void setInt(int rowIndex, int column, int what) {
data[rowIndex][column] = str(what);
}
void setInt(String rowName, int column, int what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = str(what);
}
void setFloat(int rowIndex, int column, float what) {
data[rowIndex][column] = str(what);
}
void setFloat(String rowName, int column, float what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = str(what);
}
// Write this table as a TSV file
void write(PrintWriter writer) {
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < data[i].length; j++) {
if (j != 0) {
writer.print(TAB);
}
if (data[i][j] != null) {
writer.print(data[i][j]);
}
}
writer.println();
}
writer.flush();
}
}