Update main.py
parent
e9c27990f1
commit
c01488d85c
49
main.py
49
main.py
|
|
@ -1,43 +1,12 @@
|
|||
import sys
|
||||
import pygame
|
||||
|
||||
from settings import *
|
||||
import traceback
|
||||
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()
|
||||
try:
|
||||
print("Starting game...")
|
||||
game = Game()
|
||||
print("Game initialized.")
|
||||
game.run()
|
||||
except Exception:
|
||||
print("An error occurred:")
|
||||
traceback.print_exc()
|
||||
|
|
|
|||
Loading…
Reference in New Issue