44 lines
673 B
Plaintext
44 lines
673 B
Plaintext
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()
|