Pygame 中的 2x2 像素表面

发布于 2024-11-30 14:08:29 字数 565 浏览 0 评论 0原文

我正在尝试使用 pygame 开发一款 16 位时代的游戏。 我正在使用 FlashDevelop 和 Flixel,但我想尝试一些更可靠的东西。 我遇到的问题是游戏的外观,我希望屏幕中的每个像素都“更大”,我的意思是,对于 320x240 表面中的每个像素,我需要在 640x480 表面中进行 2x2 像素投影才能获得外观Frogatto 等游戏。到处询问我发现这并不像在 Flixel 中那么容易。

你们能指导我吗?

更新

我找到了一种将缩放表面传输到主表面的方法,如下所示

screenSize = width, height = 640, 480
mainScreen = pygame.display.set_mode(screenSize)
smallScreen = pygame.Surface((320, 240))
pygame.transform.scale(smallScreen, screenSize, mainScreen)

如果有人能给我一些关于这件事的最佳实践的指导,我将不胜感激。

I'm trying to develop a 16-bit-era looking game with pygame.
I was working with FlashDevelop and Flixel but I wanted to try something more solid.
The probleme I'm having is with the look of the game, I want every pixel in screen to be "bigger", I mean, for each pixel in a 320x240 surface I need a 2x2 pixel projection in a 640x480 surface to get the look of games like Frogatto. Asking here and there I found out it's not as easy as it was in Flixel.

Can you guys guide me?

Update

I figured out a way to blit a scaled surface into the main surface as follows

screenSize = width, height = 640, 480
mainScreen = pygame.display.set_mode(screenSize)
smallScreen = pygame.Surface((320, 240))
pygame.transform.scale(smallScreen, screenSize, mainScreen)

If someone could give me some pointers in best practices about this thing, I would appreciate it.

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

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

发布评论

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

评论(2

哎呦我呸! 2024-12-07 14:08:29

不确定您是否正在寻求有关 pygame 或如何升级 320x240 的具体建议 --> 640x480 像素...

如果是后者,那么:

有几种算法可以升级像素艺术,如 MAME 使用的 - 搜索 hq2x、hq3x、hq4x;或者查看 http://en.wikipedia.org/wiki/Hqx 或更一般的内容http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms

对于您需要的内容可能有点偏离主题,但是 http ://research.microsoft.com/en-us/um/people/kopf/pixelart/index.html 显示了像素缩放方面的一些非常有趣的发展。

Not sure if you're asking for specific advice on pygame or how to upscale 320x240 --> 640x480 pixels...

If the latter, then:

There are a couple of algorithms to upscale pixel art, as used by MAME - search for hq2x, hq3x, hq4x; alternatively have a look at http://en.wikipedia.org/wiki/Hqx or more generally http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms.

Probably a bit off-topic for what you need, but http://research.microsoft.com/en-us/um/people/kopf/pixelart/index.html shows some really interesting developments in pixel scaling.

骷髅 2024-12-07 14:08:29

如果你每帧将所有各种图形绘制到位图上(就像 Flixel 所做的那样),你可以将位图的比例设置为 2.0 而不是默认的 1。

根据我对 Flixel 的了解,主类只有一个子添加到屏幕上的位图。显示的每个 flixel 对象的每一帧都会绘制到该位图。 Flixel 的比例变量只是该位图的比例。

If you draw all your various graphics onto a bitmap each frame (like what Flixel does), you can just set the scale of the bitmap to 2.0 instead of the default of 1.

From what I understand of Flixel, the main class only has one child added to the screen, a bitmap. Each flixel object that is shown is drawn each frame to that bitmap. Flixel's scale variable is just the scale of that bitmap.

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