Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用pygame缩放像素艺术游戏的最佳方式是什么?_Python_Pygame_Pixel_Scaling_Resolution - Fatal编程技术网

Python 使用pygame缩放像素艺术游戏的最佳方式是什么?

Python 使用pygame缩放像素艺术游戏的最佳方式是什么?,python,pygame,pixel,scaling,resolution,Python,Pygame,Pixel,Scaling,Resolution,精灵的显示方式与图像类似,但我希望它们显示得更大(而不会模糊像素艺术)。 我缩放了敌方和玩家类中的精灵(使用pygame.transform.scale()),并尝试了它,但我确信还有另一种更有效的解决方案;就像把所有东西放在一个曲面上,然后缩放整个曲面,而不是单独缩放每个元素 screen = pygame.display.set_mode((width, height)) while(True): player.update() #updates the character po

精灵的显示方式与图像类似,但我希望它们显示得更大(而不会模糊像素艺术)。 我缩放了敌方和玩家类中的精灵(使用pygame.transform.scale()),并尝试了它,但我确信还有另一种更有效的解决方案;就像把所有东西放在一个曲面上,然后缩放整个曲面,而不是单独缩放每个元素

screen = pygame.display.set_mode((width, height))


while(True):
  player.update()   #updates the character position

  enemy.update()


  # draw
  player_list.draw(screen) #draw player
  enemy_list.draw(screen) #draw enemy


  #pygame.transform.scale(surface, (1,1))
  screen.blit(update_fps(), (10,0))

  pygame.display.flip()
解决这个问题最好的办法是什么

使用或缩放对象:

scaled\u image=pygame.transform.smoothscale(图像,(新宽度,新高度))

我带来了一个解决方案:

对于任何想要制作像素艺术的人来说,这可能很有用:

如果你做了一个像素艺术,它可能会像这样显示

仅使用pygame.transform.scale(surface,(x,y))其中x和y是屏幕的尺寸(在我的例子中,screen=pygame.display.set_模式((640,360))就可以完美地绘制缩放后的像素艺术,这与像素艺术有多少像素无关(我建议使用Libre Sprite)


@SavannahMadison Ye当然,正因为如此,它被命名为“smoothscale”。或者,您可以使用具有相同界面的
pygame.transform.scale