Update main
parent
8bef30be97
commit
77563ec709
43
main
43
main
|
|
@ -0,0 +1,43 @@
|
|||
import sys
|
||||
import pygame
|
||||
|
||||
from settings import *
|
||||
from game import Game
|
||||
|
||||
|
||||
def initialize_pygame():
|
||||
pygame.init()
|
||||
|
||||
# Optional: control vsync if supported
|
||||
flags = pygame.SCALED
|
||||
if VSYNC:
|
||||
flags |= pygame.DOUBLEBUF
|
||||
|
||||
screen = pygame.display.set_mode(
|
||||
(SCREEN_WIDTH, SCREEN_HEIGHT),
|
||||
flags
|
||||
)
|
||||
|
||||
pygame.display.set_caption(GAME_TITLE)
|
||||
|
||||
return screen
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
screen = initialize_pygame()
|
||||
|
||||
game = Game()
|
||||
game.run()
|
||||
|
||||
except Exception as e:
|
||||
print("An error occurred:")
|
||||
print(e)
|
||||
|
||||
finally:
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue