This repository was archived by the owner on Mar 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZombie_Run.py
More file actions
145 lines (138 loc) · 3.54 KB
/
Zombie_Run.py
File metadata and controls
145 lines (138 loc) · 3.54 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import turtle
import random
import time
global zx, zy
def psetup():
turtle.penup()
turtle.goto(0, 0)
global px, py
px = turtle.xcor()
py = turtle.ycor()
def spawn_zombie():
global zx, zy
turtle.pendown()
turtle.color('green')
turtle.penup()
turtle.goto(random.randint(-850, 850), random.randint(-450, 450))
turtle.pendown()
turtle.dot(36)
turtle.penup()
turtle.color('black')
zx = turtle.xcor()
zy = turtle.ycor()
def zmove():
global zx, zy
while True:
turtle.penup()
turtle.setx(zx)
turtle.sety(zy)
time.sleep(0.1)
turtle.color('green')
support = random.randint(1, 4) # this is so the zombie has more acurate tracking, by having a thing to confirm it
if py > zy and support ==1 :
zy=zy + 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('green')
turtle.penup()
turtle.sety(zy)
turtle.pendown()
turtle.dot(36)
pmove()
elif px > zx and support ==2:
zx=zx + 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('green')
turtle.penup()
turtle.setx(zx)
turtle.pendown()
turtle.dot(36)
pmove()
elif px < zx and support ==3:
zx=zx - 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('green')
turtle.penup()
turtle.setx(zx)
turtle.pendown()
turtle.dot(36)
pmove()
elif py < zy and support ==4:
zy=zy - 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('green')
turtle.penup()
turtle.sety(zy)
turtle.pendown()
turtle.dot(36)
pmove()
def pmove():
global py, px
time.sleep(0.1)
turtle.penup()
turtle.setx(px)
turtle.sety(py)
turtle.color('black')
if abs(px - zx) < 16 and abs(py - zy) < 16:
print('You lost, the zombie ate you!')
exit()
print('move: w, a, s, d')
pdir = input()
if pdir=='w':
py=py + 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('black')
turtle.penup()
turtle.sety(py)
turtle.pendown()
turtle.dot(36)
elif pdir=='d':
px=px + 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('black')
turtle.penup()
turtle.setx(px)
turtle.pendown()
turtle.dot(36)
elif pdir=='a':
px=px - 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('black')
turtle.penup()
turtle.setx(px)
turtle.pendown()
turtle.dot(36)
elif pdir=='s':
py=py - 30
turtle.pendown()
turtle.color('white')
turtle.dot(36)
turtle.color('black')
turtle.penup()
turtle.sety(py)
turtle.pendown()
turtle.dot(36)
else:
print('Not a valid control enter a valid control next time!')
if abs(px - zx) < 16 and abs(py - zy) < 16:
print('You lost, the zombie ate you!')
exit()
time.sleep(0.1)
zmove()
turtle.dot(36)
spawn_zombie()
psetup()
pmove()