forked from arditsulceteaching/super-mario-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (35 loc) · 1.24 KB
/
main.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
import pygame
from classes.Dashboard import Dashboard
from classes.Level import Level
from classes.Menu import Menu
from classes.Sound import Sound
from entities.Mario import Mario
windowSize = 640, 480
def main():
pygame.mixer.pre_init(44100, -16, 2, 4096) # Set audio optons
pygame.init() # Initializes the library
screen = pygame.display.set_mode(windowSize) # Create a window with the size given above
max_frame_rate = 60
dashboard = Dashboard("img/font.png", 8, screen)
sound = Sound()
level = Level(screen, sound, dashboard)
menu = Menu(screen, dashboard, level, sound)
while not menu.start:
menu.update()
mario = Mario(0, 0, level, screen, dashboard, sound)
clock = pygame.time.Clock()
while not mario.restart:
pygame.display.set_caption("Super Mario running with {:d} FPS".format(int(clock.get_fps())))
if mario.pause:
mario.pauseObj.update()
else:
level.drawLevel(mario.camera)
dashboard.update()
mario.update()
pygame.display.update()
clock.tick(max_frame_rate)
return 'restart'
if __name__ == "__main__":
exitmessage = 'restart'
while exitmessage == 'restart':
exitmessage = main()