Screen displays only in top left corner of window

谁说我不能喝 提交于 2019-12-30 09:32:34

问题


I'm starting to explore Python and Pygame, however I am running into a problem. Everything I draw to the screen is only displayed in the top left quarter of the window. I thought it was my code but any demo programs I tried also display the same way.

Demo code from thenewboston on youtube

import pygame, sys
from pygame.locals import *

pygame.init()

screen = pygame.display.set_mode((640,360),0,32)

background = pygame.image.load("Background.jpg").convert()
mouse_c = pygame.image.load("ball.png").convert_alpha()

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    screen.blit(background, (0,0))

    x,y = pygame.mouse.get_pos()
    x -= mouse_c.get_width()/2
    y -= mouse_c.get_height()/2

    screen.blit(mouse_c, (x,y))

    pygame.display.update()

In the video his displays correctly and mine looks like this

Using:

  • Python 2.7.4 32 bit
  • pygame 1.9.1 32 bit
  • mac 10.8.3 64 bit on macbook pro retina

I think either it has to do with the retina display or I installed something wrong. Any help would be appreciated.


回答1:


The problem is, in fact, with the resolution of the retina screen. In order to get pygame to work correctly, download setresx and use it to set your resolution to any setting without HiDPI.



来源:https://stackoverflow.com/questions/16368487/screen-displays-only-in-top-left-corner-of-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!