-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpentix.py
65 lines (59 loc) · 2 KB
/
pentix.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
#!/usr/bin/env python3
import sys
import pygame
from pygame.locals import *
import game as gm
pygame.init()
FPS = 30
MOVING = USEREVENT + 1
FALLING = USEREVENT + 2
BOOSTING = USEREVENT + 3
START = USEREVENT + 4
def main():
resolution = (1024, 768)
game = gm.Game(False, resolution)
try:
pygame.mixer.music.load('bg.mp3')
pygame.mixer.music.play(loops=-1)
except pygame.error:
print('There is no music here')
while not game.quit:
game.draw()
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == START:
temp = game.highscore
game = gm.Game(game.fullscreen, game.screen_size)
game.highscore = temp
elif event.type == VIDEORESIZE:
game.screen_size = event.dict['size']
game.draw_main()
if game.paused:
continue
if event.type == KEYDOWN:
keys = pygame.key.get_pressed()
if keys[K_RIGHT] or keys[K_LEFT]:
game.current.move_aside(game, keys)
pygame.time.set_timer(MOVING, 300)
if keys[K_UP]:
game.current.rotate(game)
elif event.type == KEYUP:
keys = pygame.key.get_pressed()
if not keys[K_LEFT] and not keys[K_RIGHT]:
pygame.time.set_timer(MOVING, 0)
elif event.type == MOVING:
pygame.time.set_timer(MOVING, 60)
keys = pygame.key.get_pressed()
game.current.move_aside(game, keys)
elif event.type == FALLING:
game.current.fall_down(game)
elif event.type == BOOSTING:
keys = pygame.key.get_pressed()
game.current.move_down(game, keys)
pygame.display.update()
game.fpsClock.tick(FPS)
pygame.quit()
if __name__ == '__main__':
main()