def handleEvents(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.VIDEORESIZE:
global screenWidth, screenHeight, gameWidth, gameHeight
screenWidth, screenHeight = event.size
if screenWidth < self.minScreenWidth: screenWidth = self.minScreenWidth
if screenHeight < self.minScreenHeight: screenHeight = self.minScreenHeight
self.screen = pygame.display.set_mode((screenWidth, screenHeight), HWSURFACE|DOUBLEBUF|RESIZABLE)
gameWidth, gameHeight = screenWidth, screenHeight - self.toolbarHeight
self.initUI()
self.renderScreen = True
# Make sure that all food objects are within the bounds of the world.
for obj in objects:
if type(obj) is not Food: continue
if obj.pos[0] < 0: obj.pos[0] = 0
if obj.pos[1] < 0: obj.pos[1] = 0
if obj.pos[0] > screenWidth: obj.pos[0] = screenWidth
if obj.pos[1] > screenHeight: obj.pos[1] = screenHeight
self.updateKeys(event)
self.gui.event(event)
评论列表
文章目录