我用了创建了一个窗口
pygame.display.set_mode((width, height),
pygame.OPENGL | pygame.DOUBLEBUF | pygame.RESIZABLE)
Run Code Online (Sandbox Code Playgroud)
稍后在应用程序中,我希望能够向窗口询问其宽度和高度,以便我可以决定如何处理鼠标位置.
如何在程序的其他位置访问该pygame窗口的维度?(事件处理循环)
像这样!
surface = pygame.display.get_surface() #get the surface of the current active display
x,y = size = surface.get_width(), surface.get_height()#create an array of surface.width and surface.height
Run Code Online (Sandbox Code Playgroud)