forked from muccc/acab-streetlife
-
Notifications
You must be signed in to change notification settings - Fork 1
/
acabsl.py
executable file
·76 lines (59 loc) · 1.5 KB
/
acabsl.py
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
#!/usr/bin/python
import urllib2
import socket
from hosts import *
#HOST="127.1"
#PORT=8080
UDPHOST=SERVER_HOST
UDPPORT=5008
#SIMULATORPORT=4006
WALLSIZEX=10
WALLSIZEY=9
NOOFWALLS=1
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def send(w, x, y, r, g, b, t=0):
w=int(w)
x=int(x)
y=int(y)
r=int(r)
g=int(g)
b=int(b)
ms = int(t * 1000)
# recalculate x and y based on input x,y and wall no w
x = w * WALLSIZEX + x
msg = "%c%cC%c%c%c%c%c"%(x, y, r, g, b, ms>>8, ms&0xFF)
sock.sendto(msg, (UDPHOST, UDPPORT))
#sock.sendto(msg, (UDPHOST, SIMULATORPORT))
def update(buffered = True):
if buffered:
msg = "%c%cU%c%c%c%c%c"%(1, 0, 0, 0, 0, 0, 0)
else:
msg = "%c%cU%c%c%c%c%c"%(0, 0, 0, 0, 0, 0, 0)
sock.sendto(msg, (UDPHOST, UDPPORT))
#sock.sendto(msg, (UDPHOST, SIMULATORPORT))
def speedfade(w, x, y, r, g, b, speed):
w=int(w)
x=int(x)
y=int(y)
r=int(r)
g=int(g)
b=int(b)
# recalculate x and y based on input x,y and wall no w
x = w * WALLSIZEX + x
msg = "%c%cF%c%c%c%c%c"%(x, y, r, g, b, speed>>8, speed&0xFF)
sock.sendto(msg, (UDPHOST, UDPPORT))
#sock.sendto(msg, (UDPHOST, SIMULATORPORT))
def matrix(targetsize_x=WALLSIZEX, targetsize_y=WALLSIZEY):
x=0
y=0
matrix = []
while(y < targetsize_y):
while(x < targetsize_x):
p = (x,y)
matrix.append(p)
x = x + 1
y = y + 1
x = 0
return matrix
update(False)
update(False)