-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouseClicked.js
More file actions
69 lines (52 loc) · 2.01 KB
/
Copy pathmouseClicked.js
File metadata and controls
69 lines (52 loc) · 2.01 KB
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
function mouseClicked() {
var clickedParticle = null;
//if the mouse is over the particle and the mouse button is clicked, then particle becomes 'clickedParticle'
for (var i = 0; i < particleSystem.length; i++) {
var particle = particleSystem[i];
if (particle.getMouseOverC()) {
clickedParticle = particle;
}
}
var posX = width / 8;
var posY = height / 1.1;
var overButton = (mouseX >= posX && mouseX <= posX + 80 && mouseY >= posY && mouseY <= posY + 30);
//if clickedParticle exists
if (clickedParticle != null) {
//dump those arrays so that you only have the clicked particle
isSingleCompany = true;
attractors[0].pos.set(width/2 + 50, height / 1.1);
investorDisplay = [];
companiesDisplay = [];
connectionsDisplay = [];
var cname = clickedParticle.name;
connections.forEach(function (c) {
if (cname == c.company.name) {
var iname = c.investor.name;
var iparticle = getInvestorParticle(iname);
var foundInvestor = investorDisplay.find(function (element) {
if (element == iparticle) return true;
else return false;
});
if (!foundInvestor) {
investorDisplay.push(iparticle);
}
}
});
companiesDisplay.push(clickedParticle);
specialConnections.forEach(function (sc) {
if (sc.companyParticle == clickedParticle) {
connectionsDisplay.push(sc);
}
});
//reset data structure
} else if(overButton){
isSingleCompany = false;
attractors[0].pos.set(width/2, height/2);
companiesDisplay = [];
investorDisplay = [];
connectionsDisplay = [];
particleSystem.forEach(function (p) {
companiesDisplay.push(p);
});
}
}