Skip to content
Snippets Groups Projects
Commit 29296157 authored by nicolas.albanesi's avatar nicolas.albanesi
Browse files

sending message to x y matrix working

parent efe7cfbc
Branches
No related tags found
1 merge request!1merge Nico
......@@ -10,23 +10,16 @@ def send_passthrough(msg, x, y):
x = int(x)
y = int(y)
newx = x
newy = y
if x > id[0]:
d = O
newx += 1
elif x < id[0]:
d = E
newx -= 1
elif x < id[0]:
d = O
elif y > id[1]:
d = S
newy += 1
else:
d = N
newy -= 1
else:
d = S
envoyer_msg(d, "PT;{},{};{}".format(newx, newy, msg))
envoyer_msg(d, "PT;{},{};{}".format(x, y, msg))
def send_xy(x, y, msg):
send_passthrough(msg, x, y)
......@@ -57,9 +50,7 @@ def update_id(new_id):
display_id()
def handle_receive(msg, d):
msg = msg_to_str(msg)
if msg.startswith("SET_ID"):
tmp_id = msg[7:].split(",")
......@@ -77,16 +68,29 @@ def handle_receive(msg, d):
m = msgs[2]
x, y = msgs[1].split(",")
x = int(x)
y = int(y)
if x == id[0] and y == id[1]:
handle_receive(m, d)
return
send_passthrough(m, int(x), int(y))
send_passthrough(m, x, y)
# Main
afficher_texte("Ready", VERT, speed=0.01)
while True:
for d in [N, S, E, O]:
msg = recevoir_msg(d)
if msg == b"": continue
msg = msg_to_str(msg)
handle_receive(msg, d)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment