File tree 2 files changed +31
-6
lines changed
2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,23 @@ def draw():
32
32
p2head = p2xy .copy ()
33
33
34
34
if p1head in p1body or p1head in p2body :
35
- print ("Cyan wins!" )
35
+ turtle .clear ()
36
+ turtle .penup ()
37
+ turtle .goto (- 65 ,0 )
38
+ turtle .pendown ()
39
+ turtle .color ('cyan' )
40
+ turtle .write ('Cyan wins!' ,font = ('Arial' ,20 ))
36
41
return
42
+
37
43
if p2head in p2body or p2head in p1body :
38
- print ("Orange wins!" )
44
+ turtle .clear ()
45
+ turtle .penup ()
46
+ turtle .goto (- 80 ,0 )
47
+ turtle .pendown ()
48
+ turtle .color ('orange' )
49
+ turtle .write ("Orange wins!" ,font = ('Arial' ,20 ))
39
50
return
51
+
40
52
p1body .add (p1head )
41
53
p2body .add (p2head )
42
54
Original file line number Diff line number Diff line change 15
15
p2aim = vector (- 4 , 0 )
16
16
p2body = set ()
17
17
18
+
18
19
def inside (head ):
19
20
return - 200 < head .x < 200 and - 200 < head .y < 200
20
21
22
+
21
23
def draw ():
22
24
p1xy .move (p1aim )
23
25
p1head = p1xy .copy ()
@@ -26,11 +28,21 @@ def draw():
26
28
p2head = p2xy .copy ()
27
29
28
30
if p1head in p1body or p1head in p2body :
29
- print ('Cyan wins!' )
31
+ turtle .clear ()
32
+ turtle .penup ()
33
+ turtle .goto (- 65 , 0 )
34
+ turtle .pendown ()
35
+ turtle .color ('cyan' )
36
+ turtle .write ('Cyan wins!' , font = ('Arial' , 20 ))
30
37
return
31
-
38
+
32
39
if p2head in p2body or p2head in p1body :
33
- print ('Orange wins!' )
40
+ turtle .clear ()
41
+ turtle .penup ()
42
+ turtle .goto (- 80 , 0 )
43
+ turtle .pendown ()
44
+ turtle .color ('orange' )
45
+ turtle .write ("Orange wins!" , font = ('Arial' , 20 ))
34
46
return
35
47
36
48
p1body .add (p1head )
@@ -41,6 +53,7 @@ def draw():
41
53
turtle .update ()
42
54
turtle .ontimer (draw , 50 )
43
55
56
+
44
57
turtle .listen ()
45
58
turtle .onkey (lambda : p1aim .rotate (90 ), 'a' )
46
59
turtle .onkey (lambda : p1aim .rotate (- 90 ), 'd' )
@@ -49,4 +62,4 @@ def draw():
49
62
50
63
draw ()
51
64
52
- turtle .mainloop ()
65
+ turtle .mainloop ()
You can’t perform that action at this time.
0 commit comments