-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.pde
170 lines (152 loc) · 4.33 KB
/
Player.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
class Player {
//Movement variables for objects
PVector loc;
PVector vel;
PVector acc;
//Attributes of each object
String draftedby;
String name;
int time;
int num;
float GVT;
float pointsGP;
float ht;
float wt;
float expectedGVT;
//Determines how fast objects move
float maxspeed = 7;
float maxforce = 3;
//Size and color of objects
float circleSizeX;
float circleSizeY;
color expectedColor = color(255, 0);
//Bringing in the data to the object
Player(String _draftedby, String _name, int _time, int _num, float _GVT, float _pointsGP, float _ht, float _wt, float _expectedGVT) {
draftedby = _draftedby;
name = _name;
time = _time;
num = _num;
GVT = _GVT;
pointsGP = _pointsGP;
ht = _ht;
wt = _wt;
expectedGVT = _expectedGVT;
circleSizeX = 10;
circleSizeY = 10;
loc = new PVector((time-1990)*20+30, height-num*20-50);
acc = new PVector(0, 0);
vel = new PVector(0, 0);
}
// Arrive function moves object to the target
void arrive(PVector target) {
acc.add(steer(target));
}
// Steer function returns a vector that changes (as necessary) as we move to the desired location
PVector steer(PVector target) {
PVector steer;
PVector desired = PVector.sub(target, loc);
float d = desired.mag();
if (d > 0) {
desired.normalize();
if (d < 1000) desired.mult(maxspeed*(d/100.0f));
steer = PVector.sub(desired, vel);
steer.limit(maxforce);
}
else {
steer = new PVector(0, 0);
}
return steer;
}
//Adding up the acceleration to velocity, limiting max speed and implementing to our location
void update() {
vel.add(acc);
vel.limit(maxspeed);
loc.add(vel);
acc.mult(0);
}
//Drawing the object
void display() {
noStroke();
fill(expectedColor);
ellipse(loc.x, loc.y, expectedGVT*1.9, expectedGVT*1.9);
fill(100, 140, 200, 200);
ellipse(loc.x, loc.y, circleSizeX, circleSizeY);
}
//This function determines how each object moves, based on its attributes and what 'mode' we are in.
void perform() {
if (GVTtrigger) {
expectedColor = color(255, 100, 100, 100);
arrive(new PVector((time-1990)*20+30, height-GVT*20-50));
circleSizeX = lerp(circleSizeX, GVT*1.9, 0.01);
circleSizeY = lerp(circleSizeY, GVT*1.9, 0.01);
}
if (HTtrigger) {
expectedColor = color(255, 0);
arrive(new PVector((time-1990)*20+30, height-num*20-50));
if (ht > 60) {
circleSizeY = lerp(circleSizeY, (ht-65)*1.5, 0.1);
}
if (wt > 130) {
circleSizeX = lerp(circleSizeX, (wt-160)/5+5, 0.1);
}
}
if (resettrigger) {
expectedColor = color(255, 0);
arrive(new PVector((time-1990)*20+30, height-num*20-50));
circleSizeX = lerp(circleSizeX, 10, 0.1);
circleSizeY = lerp(circleSizeY, 10, 0.1);
}
}
//Packaging up all the functions in the object
void run() {
update();
perform();
display();
}
//Displaying the words associated with objects
void words() {
fill(0);
if (!GVTtrigger && !HTtrigger) {
if (dist(mouseX, mouseY, loc.x+transX, loc.y+transY) < circleSizeX/2+4) {
if (GVT < expectedGVT) {
fill(230, 180, 180);
}
else {
fill(180, 180, 240);
}
ellipse(522, height-num*20-55, 8, 8);
fill(255);
textSize(12);
text(name + ", " + draftedby + " (" + time + ")", 530, height-num*20-50);
}
}
else if (GVTtrigger) {
if (dist(mouseX, mouseY, loc.x+transX, loc.y+transY) < circleSizeX/2+4) {
if (GVT < expectedGVT) {
fill(230, 180, 180);
}
else {
fill(180, 180, 230);
}
ellipse(522, height-num*20-55, 8, 8);
fill(255);
textSize(12);
text(name + ", GVT: " + round(GVT*10.0f)/10.0f + " | Expected: " + round(expectedGVT*10.0f)/10.0f, 530, height-num*20-50);
}
}
else if (HTtrigger) {
if (dist(mouseX, mouseY, loc.x+transX, loc.y+transY) < circleSizeX/2+4) {
if (GVT < expectedGVT) {
fill(230, 180, 180);
}
else {
fill(180, 180, 230);
}
ellipse(522, height-num*20-55, 8, 8);
fill(255);
textSize(12);
text(name + ", " + ht + " in, " + wt + " lbs", 530, height-num*20-50);
}
}
}
}