-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_player.py
99 lines (78 loc) · 2.13 KB
/
single_player.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
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
import turtle
import random
import torch
import show_classes as c
import numpy as np
import copy
import time
def jump(Ball, v):
Ball.velocity += v
def single_main():
print("Please chose a level from 1, 2 and 3")
level = int(input())
if level == 1:
v = 8
limit = True
elif level == 2:
v = 40
limit = True
elif level == 3:
v = 40
limit = False
window = turtle.Screen()
turtle.getscreen()._root.attributes('-topmost', 1)
turtle.getscreen()._root.attributes('-topmost', 0)
window.title("game")
window.bgcolor("black")
window.setup(width=800,height=600)
window.tracer(0)
Pipes = []
Balls = []
Balls.append(c.Ball(1))
window.listen()
if level == 1:
window.onkeypress(Balls[0].Up,"w")
window.onkeypress(Balls[0].Up,"w")
else:
window.onkeypress(Balls[0].Up_2,"w")
count = 0
Pipes.append(c.Pipe(50,-300))
Game = True
while Game == True:
time.sleep(1/30)
window.update()
if count % 70 == 0:
Pipes.append(c.Pipe(400,-300))
counter = 0
for i in Balls:
i.move()
if i.alive == True:
i.score = count
if limit == True:
if i.gety()>300:
i.sety(300)
i.velocity = 8
if i.gety()<-300:
print("I Fell Down")
Game = False
i.check_for_hit(Pipes[0])
if i.alive == False:
counter +=1
i.update_color()
if counter == 1:
print("You fucked up")
Game = False
for i in Pipes:
i.move()
if i.getx() < -400:
i.pipe.reset()
i.pipe1.reset()
del i
del Pipes[0]
count = count+1
window.clear()
window.bye()
del Balls
return True
if __name__=="__main__":
single_main()