屏幕仅显示在窗口的左上角 [英] Screen displays only in top left corner of window

查看:74
本文介绍了屏幕仅显示在窗口的左上角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始探索 Python 和 Pygame,但是我遇到了一个问题.我在屏幕上绘制的所有内容仅显示在窗口的左上角四分之一处.我以为这是我的代码,但我尝试过的任何演示程序也以相同的方式显示.

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.

来自 youtube 上 thenewboston 的演示代码

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

使用:

  • Python 2.7.4 32 位
  • pygame 1.9.1 32 位
  • macbook pro 视网膜上的 mac 10.8.3 64 位

我认为要么与视网膜显示器有关,要么我安装了错误的东西.任何帮助将不胜感激.

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

推荐答案

问题,其实就是视网膜屏幕的分辨率.为了让 pygame 正常工作,请下载 setresx 并使用它来将您的分辨率设置为没有 HiDPI 的任何设置.

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.

这篇关于屏幕仅显示在窗口的左上角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆