-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPinball.pde
48 lines (38 loc) · 885 Bytes
/
Pinball.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
Board board;
ArrayList<Particle> balls;
float dt = 0.5;
float radius = 20.0;
float Kr = 0.99;
void setup()
{
size(1000, 1000);
board = new Board();
balls = new ArrayList<Particle>();
}
void draw()
{
background(150, 150, 150);
rect (100, 100, 800, 800);
// Actualización de las partículas
for (int i = 0; i < balls.size(); i++)
{
Particle p = balls.get(i);
p.update();
for (int j=i+1;j<balls.size();j++){
Particle q = balls.get(j);
p.checkCollisions_ParticleParticle(q);
}
p.display();
}
// Cálculo de las las colisiones
board.update();
// Dibujado el pinball
board.display();
}
void mousePressed()
{
// A la pulsación del ratón por parte del usuario, introduce una nueva bola
PVector pos = new PVector(mouseX, mouseY);
Particle p = new Particle(pos, radius);
balls.add(p);
}