-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_1.py
More file actions
64 lines (59 loc) · 1.18 KB
/
Copy pathmap_1.py
File metadata and controls
64 lines (59 loc) · 1.18 KB
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
import turtle
import random
#---------------------------------
screen=turtle.Screen()
screen.title("MAP_1")
screen.bgcolor("lightgreen")
# costumising turtles
t1=turtle.Turtle()
t2 = turtle.Turtle()
target1 = turtle.Turtle()
target2 = turtle.Turtle()
target1.hideturtle()
target2.hideturtle()
t1.penup()
t2.penup()
t1.shape("turtle")
t2.shape("turtle")
t1.color("red")
#controls for player
def w():
t1.forward(random.randrange(3))
def s():
t1.backward(10)
'''def up():
t1.forward(random.randrange(3))
def down():
t1.backward(10)'''
# 2 turtle
t2.goto(-100,-100)
t2.left(90)
#1 turtle
t1.left(90)
t1.goto(100,-100)
#3 costemising target1
target1.penup()
target1.goto(-100,100)
target1.pendown()
target1.circle(15)
# costimising target2
target2.penup()
target2.goto(100,100)
target2.pendown()
target2.circle(15)
#time to race
#player
turtle.onkeypress(w, "w")
turtle.onkeypress(s, "s")
#turtle.onkeypress(up, "up")
#turtle.onkeypress(down, "down")
turtle.listen()
#computer
for x in range(425):
t2.forward(random.randrange(2))
if (t1.position()[1]) >= 100:
print("player wins!")
break
elif (t2.position()[1]) == 100:
print("computer wins!")
#t.clear()