Skip to content

Commit 6f56085

Browse files
committed
Update winner message (TRON - 1 and 2 Players)
1 parent b1dca8c commit 6f56085

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

TRON (1 Player)/main.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,23 @@ def draw():
3232
p2head = p2xy.copy()
3333

3434
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))
3641
return
42+
3743
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))
3950
return
51+
4052
p1body.add(p1head)
4153
p2body.add(p2head)
4254

TRON (2 Player)/main.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
p2aim = vector(-4, 0)
1616
p2body = set()
1717

18+
1819
def inside(head):
1920
return -200 < head.x < 200 and -200 < head.y < 200
2021

22+
2123
def draw():
2224
p1xy.move(p1aim)
2325
p1head = p1xy.copy()
@@ -26,11 +28,21 @@ def draw():
2628
p2head = p2xy.copy()
2729

2830
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))
3037
return
31-
38+
3239
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))
3446
return
3547

3648
p1body.add(p1head)
@@ -41,6 +53,7 @@ def draw():
4153
turtle.update()
4254
turtle.ontimer(draw, 50)
4355

56+
4457
turtle.listen()
4558
turtle.onkey(lambda: p1aim.rotate(90), 'a')
4659
turtle.onkey(lambda: p1aim.rotate(-90), 'd')
@@ -49,4 +62,4 @@ def draw():
4962

5063
draw()
5164

52-
turtle.mainloop()
65+
turtle.mainloop()

0 commit comments

Comments
 (0)