Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.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 - Fatal编程技术网

Python Pygame:设置一个从表面擦除的圆

Python Pygame:设置一个从表面擦除的圆,python,pygame,Python,Pygame,我有一个复杂的问题,我想我想知道是否有人能帮我。对于我正在开发的游戏,我需要一个战争迷雾,只有某些点不会被黑暗覆盖,我认为最好的方法是设置一个填充为(0,0,0)的曲面,使其具有黑暗,然后以某种方式存在第二个曲面,以从第一个曲面中删除,并显示下面的所有内容 我有办法做到这一点吗 import pygame pygame.init() display = (1280,720) screen = pygame.display.set_mode(display, 0, 32) screen.

我有一个复杂的问题,我想我想知道是否有人能帮我。对于我正在开发的游戏,我需要一个战争迷雾,只有某些点不会被黑暗覆盖,我认为最好的方法是设置一个填充为(0,0,0)的曲面,使其具有黑暗,然后以某种方式存在第二个曲面,以从第一个曲面中删除,并显示下面的所有内容

我有办法做到这一点吗

import pygame
pygame.init()    

display = (1280,720)
screen = pygame.display.set_mode(display, 0, 32)
screen.fill((255,255,255)) # Fill the screen white so you can see when fog of war is lifted
fog_of_war = pygame.Surface(display)
fog_of_war.fill((0,0,0)) # creates surface size of the display and fills it black, nothing can be seen.
pygame.draw.circle(fog_of_war,(60,60,60),(200,200),100,0)
fog_of_war.set_colorkey((60,60,60)) #This is the important part, first we drew a circle on the fog of war with a certain color which we now set to transparent.
screen.blit(fog_of_war,(0,0))
pygame.display.update()

因此,您在问题中所考虑的过程运行良好。在战争迷雾表面上任何你想要有视觉的地方,只要用你设置为透明的颜色画一些东西,你可以在你想要的任何地方做这件事。

这个相关的问题可能会有帮助: