Pygame缩放屏幕

发布于 2025-02-08 15:11:45 字数 357 浏览 2 评论 0原文

我现在正在用32x32纹理写游戏,因为我的屏幕窗口太小,我有问题吗?我可以“缩放”整个游戏吗? wo14t.png“ alt =”在此处输入图像描述”>

现在看起来像这样,而我想要的是使整个屏幕更大和变焦只能看到地图的5%。

当然,如果我使屏幕更大,那将不会解决我的问题。 也许我应该添加另一台相机之类的东西?

我认为我很清楚自己。 谢谢!

im writing a game right now with 32x32 textures, i have a problem because my screen window is too small, is there any solution? Can i "zoom" my whole game?enter image description here

Now it looks like this and exactly what i want is to make whole screen bigger and zoom to see only like 5% of map.

Of course, if i make my screen bigger it not gonna fix my problem.
Maybe i should add another camera or something?
enter image description here

I think I made myself quite clear.
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉酒的小男人 2025-02-15 15:11:45

首先,您肯定可以像您所说的那样放大。

screen.blit(pygame.transform.scale(display, (int(width), int(height)))

您可以调整屏幕大小:

screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT),pygame.RESIZABLE)
def resize(event):
    global WINDOWWIDTH, WINDOWHEIGHT
    if event.type == pygame.VIDEORESIZE:
        WINDOWWIDTH = event.size[0]
        WINDOWHEIGHT = event.size[1]
        return pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), pygame.RESIZABLE)

并将显示器显示为要绘制的实际尺寸到:

display = pygame.Surface((300,200))

但是,缩放表面确实很糟糕,因为像素艺术在缩放范围方面不佳。另一种选择是摄像头或关闭pygame,这将使您试图做的一切变得不那么复杂。我建议 rubato 开始。它将为您完成所有这些工作,您可以决定使用一个变量的实际网格(显示)。

祝你好运!如果您需要额外的帮助,请随时发表评论。

First, you can definitely zoom as you are saying.

screen.blit(pygame.transform.scale(display, (int(width), int(height)))

You can resize the screen:

screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT),pygame.RESIZABLE)
def resize(event):
    global WINDOWWIDTH, WINDOWHEIGHT
    if event.type == pygame.VIDEORESIZE:
        WINDOWWIDTH = event.size[0]
        WINDOWHEIGHT = event.size[1]
        return pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), pygame.RESIZABLE)

And have the display the actual size you want to draw to:

display = pygame.Surface((300,200))

However, scaling surfaces is really bad as pixel art isn't great at scaling. An alternative would be a camera or switching off of pygame which would make everything you are trying to do way less complicated. I would recommend rubato for a start. It will do all this work for you, and you can decide how big you want your actual grid (display) to be with one variable.

Good luck! Feel free to comment if you want any extra help.

万水千山粽是情ミ 2025-02-15 15:11:45

您可以解决此问题的一种方法是缩小屏幕本身的大小:

#you can adjust the width and height in game until it seems the right fit
screen=pygame.display.set_mode((WIDTH,HEIGHT))

如果需要,可以将窗口设置为全屏:

screen=pygame.display.set_mode((WIDTH,HEIGHT),pygame.FULLSCREEN)

One way you can fix this is by shrinking the size of the screen itself:

#you can adjust the width and height in game until it seems the right fit
screen=pygame.display.set_mode((WIDTH,HEIGHT))

And if you want, you can set the window to Fullscreen:

screen=pygame.display.set_mode((WIDTH,HEIGHT),pygame.FULLSCREEN)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文