-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.pde
71 lines (58 loc) · 1.85 KB
/
Board.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
class Board {
ArrayList<Plane> planes;
// Constructor de la clase Tablón
Board() {
planes = new ArrayList<Plane>();
// Planos del perímetro
Plane up = new Plane(100, 100, width - 100, 100);
Plane down = new Plane(100, height - 100, width - 100, height - 100);
Plane left = new Plane(100, 100, 100, height - 100);
Plane right = new Plane(width - 100, 100, width - 100, height - 100);
// Planos interiores situados en los bordes
Plane one = new Plane(250, 300, 300, 250);
Plane two = new Plane(width - 250, 300, width - 300, 250);
Plane three = new Plane(250, height - 300, 300, height - 250);
Plane four = new Plane(width - 250, height - 300, width - 300, height - 250);
// Planos interiores situados en el centro en forma de X
Plane five = new Plane(500, 500, 450, 450);
Plane six = new Plane(500, 500, 550, 550);
Plane seven = new Plane(500, 500, 450, 550);
Plane eight = new Plane(500, 500, 550, 450);
planes.add(up);
planes.add(down);
planes.add(left);
planes.add(right);
planes.add(one);
planes.add(two);
planes.add(three);
planes.add(four);
planes.add(five);
planes.add(six);
planes.add(seven);
planes.add(eight);
}
// Cálculo de las colisiones
void update()
{
for (int i = planes.size()-1; i >= 0; i--)
{
Plane plane = planes.get(i);
for (int j=0; j<balls.size(); j++)
{
Particle p = balls.get(j);
plane.checkCollisions_ParticlePlane(p);
}
}
}
// Dibujado el pinball
void display()
{
fill(0, 255, 0);
strokeWeight(2);
for (int i=0;i<planes.size();i++)
{
Plane plane = planes.get(i);
line(plane.point1.x, plane.point1.y, plane.point2.x, plane.point2.y);
}
}
}