-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTurtle game.py
54 lines (47 loc) · 1002 Bytes
/
Turtle game.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 turtle
input("Use 'w,a,s,d' to move, space to shoot, mouse click to teleport.(Enter for start) ")
#screen
screen = turtle.Screen()
screen.bgcolor("lightgreen")
#player
pen = turtle.Turtle()
pen.pu()
pen.color("green")
pen.speed(0)
#defs
spd = 1
m = pen
def f():
global spd
spd += 1
def ri():
pen.right(30)
def le():
pen.left(30)
def slow():
global spd
spd -= 1
def shoot():
global pen
bull = turtle.Turtle()
bull.shape("circle")
bull.pu()
bull.speed(100)
bull.shapesize(0.5, 0.5, 0.5)
bull.setposition(round(pen.xcor(), 1), round(pen.ycor(), 1))
bull.left(pen.heading())
bull.speed(2)
bull.forward(200)
bull.ht()
print(bull.shapesize())
turtle.onkeypress(f, "w")
turtle.onkeypress(ri, "d")
turtle.onkeypress(le, "a")
turtle.onkeypress(slow, "s")
turtle.onkeypress(shoot, "space")
screen.onclick(pen.goto)
wasd = screen.textinput("Name", "Name: ")
turtle.listen()
# main part
while True:
pen.forward(spd)