-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathturtle_client.py
54 lines (37 loc) · 965 Bytes
/
turtle_client.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
import socket
class Turtle:
BUFFER_SIZE = 1024
DEFAULT_PORT = 1337
def __init__(self, host, port=DEFAULT_PORT):
self.host, self.port = host, port
def forward(self, x):
self.__send_command("F", x)
def backward(self, x):
self.__send_command("B", x)
def left(self, x):
self.__send_command("L", x)
def right(self, x):
self.__send_command("R", x)
def penup(self):
self.__send_command("U")
def pendown(self):
self.__send_command("D")
def speed(self, s):
pass
def color(self, _):
pass
def setposition(self, x, y):
pass
def position(self):
return (0, 0)
def hideturtle(self):
pass
def showturtle(self):
pass
def __send_command(self, *args):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((self.host, self.port))
self.socket.send(" ".join(map(str, args)))
#data = s.recv(BUFFER_SIZE)
self.socket.close()
Pen = Turtle