-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface_test.py
77 lines (63 loc) · 1.61 KB
/
interface_test.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
from game import pg, Screen, GameObject
from pygame.time import Clock
def get_close():
for event in pg.event.get():
if event.type == pg.QUIT:
return True
else:
return False
screen = Screen()
SNAKE = pg.image.load('assets/img/icon.png')
SNAKE = pg.transform.scale(SNAKE,(90,90))
KUNAI = pg.image.load('assets/img/kunai.png')
KUNAI = pg.transform.scale(KUNAI,(34,90))
master = GameObject(screen, SNAKE, y=180, vy=-15)
slv1 = GameObject(master, SNAKE, -200,100)
slv2 = GameObject(slv1, SNAKE, -200,100)
sword = GameObject(slv1, KUNAI, y=-SNAKE.get_rect().size[1])
w = 25
angle = w
clock = Clock()
clock_tick = 30
for i in range(33):
if get_close():
exit()
screen.update()
clock.tick(clock_tick)
master.update()
slv1.update()
slv2.update()
sword.set_img(pg.transform.rotate(KUNAI,angle))
sword.set_pos(sword.get_pos().rotate(-w))
angle += w
angle %= 360
master.set_spd((10,0))
slv1.set_spd((-10,0))
slv2.set_spd((10,10))
for i in range(40):
if get_close():
exit()
screen.update()
clock.tick(clock_tick)
master.update()
slv1.update()
slv2.update()
sword.set_img(pg.transform.rotate(KUNAI,angle))
sword.set_pos(sword.get_pos().rotate(-w))
angle += w
angle %= 360
master.set_spd((0,0))
slv1.set_spd((0,0))
slv2.set_spd((0,0))
while True:
if get_close():
exit()
screen.update()
clock.tick(clock_tick)
master.update()
slv1.update()
slv2.update()
sword.set_img(pg.transform.rotate(KUNAI,angle))
sword.set_pos(sword.get_pos().rotate(-w))
angle += w
angle %= 360