/** * Jason R. Bailey * * NBA players designed based on 2008 season statistics * Head Height = FGM * Head With = FGA * Arm Length = BK * Leg Length = TR * Eye Height = Ast * Eye Width = Turnovers */ Record[] records; String[] lines; int recordCount; PFont body; int num = 4; // Display this many entries on each screen. int startingEntry = 0; // Display from this entry number int nextEntry = 0; int threesMade = 0; int threesTaken = 0; int FGTaken = 0; int FGMade = 0; int BK = 0; int AS = 0; int TO = 0; void setup() { size(1200, 650); fill(255); noLoop(); body = loadFont("ArialMT-28.vlw"); textFont(body); lines = loadStrings("players.txt"); records = new Record[lines.length]; for (int i = 0; i < lines.length; i++) { String seperators = WHITESPACE + ",::?()|-"; String[] pieces = splitTokens(lines[i], seperators); // Load data into arrayif (pieces.length == 9) { records[recordCount] = new Record(pieces); recordCount++; } } void draw() { smooth(); background(205,207,205); noStroke(); fill (20,20,20,250); pushMatrix(); rect (105,300,50,50); rect (405,300,50,50); rect (705,300,50,50); rect (1005,300,50,50); popMatrix(); for (int i = 0; i < num; i++) { fill (20,20,20,250); pushMatrix(); textFont(body); int nextEntry = startingEntry + i; int thisEntry = startingEntry + i; text(records[nextEntry].first + " " + records[thisEntry].last, 30 + i*300, 40); popMatrix(); fill (143,127,90,250); pushMatrix(); int FGTaken = startingEntry + i; int FGMade = startingEntry + i; ellipse(130 + i*300,300-records[FGTaken].FGA/16,records[FGTaken].FGA/8, records[FGMade].FGM/4); //rect(20,30 + i*50,records[FGMade].FGM/2, 5); popMatrix(); fill (143,127,90,250); pushMatrix(); int totalRebounds = startingEntry + i; rect(132 + i*300,355,15, records[totalRebounds].TR/4); rect(113 + i*300,355,15, records[totalRebounds].TR/4); int blockShots = startingEntry + i; rect(90 + i*300,300,10, records[blockShots].BK+10); rect(160 + i*300,300,10, records[blockShots].BK+10); popMatrix(); fill (250,250,250,250); pushMatrix(); int assists = startingEntry + i; int turnovers = startingEntry + i; ellipse(130+records[FGMade].FGM/16 + i*300,300-records[FGTaken].FGA/16,records[turnovers].TR/12-5, records[assists].AS/8); ellipse(130-records[FGMade].FGM/16 + i*300,300-records[FGTaken].FGA/16,records[turnovers].TR/12-5, records[assists].AS/8); popMatrix(); } } void mousePressed() { startingEntry += num; if (startingEntry + num > records.length) { startingEntry -= num; nextEntry -= num; threesMade -= num; threesTaken -= num; FGTaken -= num; FGMade -= num; BK -= num; AS -= num; TO -= num; } redraw(); } class Record { String last; String first; String team; String position; int GP; int Min; int FGM; int FGA; int Three; int ThreeA; int FTM; int FTA; int OR; int TR; int AS; int ST; int TO; int BK; int PF; int DQ; int PTS; int TC; int EJ; int FF; int Sta; public Record(String[] pieces) { last = (pieces[0]); first = (pieces[1]); team = (pieces[2]); position = (pieces[3]); GP = int(pieces[4]); Min = int(pieces[5]); FGM = int(pieces[6]); FGA = int(pieces[7]); Three = int(pieces[8]); ThreeA = int(pieces[9]); FTM = int(pieces[10]); FTA = int(pieces[11]); OR = int(pieces[12]); TR = int(pieces[13]); AS = int(pieces[14]); ST = int(pieces[15]); TO = int(pieces[16]); BK = int(pieces[17]); PF = int(pieces[18]); DQ = int(pieces[19]); PTS = int(pieces[20]); TC = int(pieces[21]); EJ = int(pieces[22]); FF = int(pieces[23]); Sta = int(pieces[24]); } }