-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocket.pde
66 lines (60 loc) · 1.23 KB
/
Socket.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
class Socket //<>//
{
int grosor;
int posX;
int posY;
int orden;
String estado;
color colr;
Cuerda miCuerda;
Socket(int _posX, int _posY, String _estado)
{
posX = _posX;
posY = _posY;
estado = _estado;
grosor = diametroSocket;
}
void dibujar()
{
if (dist(mouseX, mouseY, posX, posY) < grosor/2 && mouseApretado)
{
if (estado == "disponible" && (cantActivos < maxActivos))
{
++cantActivos;
estado = "soga";
miCuerda = new Cuerda(posX, posY, this);
++ordenSogas;
orden = ordenSogas;
} else if (estado == "soga")
{
miCuerda.destroy();
miCuerda = null;
--cantActivos;
estado = "disponible";
}
}
if (estado == "soga")
{
fill(255);
miCuerda.dibujar();
} else
{
fill(0);
}
if (estado == "soga" || estado == "disponible")
{
pushStyle();
noStroke();
ellipse(posX, posY, grosor, grosor);
popStyle();
}
}
int getSocketHeight()
{
return round(float(posY - 16) / ( float(height)/float(maSockets.length-1)));
}
int getSocketWidth()
{
return round(float(posX - 56) / ( float(width)/float(maSockets[0].length-1)));
}
}