Item Fehler gefixt
This commit is contained in:
parent
b0b979d80b
commit
f41f872243
2 changed files with 35 additions and 1 deletions
2
game.py
2
game.py
|
|
@ -26,8 +26,8 @@ class Item:
|
||||||
self.visible: bool = False
|
self.visible: bool = False
|
||||||
self.flashlight = flashlight
|
self.flashlight = flashlight
|
||||||
self.game = game
|
self.game = game
|
||||||
self.mask = pygame.mask.Mask(self.rect.size, fill=True)
|
|
||||||
self.image = image
|
self.image = image
|
||||||
|
self.mask = pygame.mask.Mask(self.rect.size, fill=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rect(self) -> pygame.Rect:
|
def rect(self) -> pygame.Rect:
|
||||||
|
|
|
||||||
34
testen/masken.py
Normal file
34
testen/masken.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import pygame
|
||||||
|
|
||||||
|
pygame.init()
|
||||||
|
screen = pygame.display.set_mode((1280, 720))
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
running = True
|
||||||
|
|
||||||
|
image = pygame.Surface((200, 200), pygame.SRCALPHA)
|
||||||
|
image.fill("blue")
|
||||||
|
pygame.draw.rect(image, "red", (0, 100, 200, 100))
|
||||||
|
|
||||||
|
selection = pygame.Surface((200, 200), pygame.SRCALPHA)
|
||||||
|
pygame.draw.circle(selection, "white", (100, 100), 80)
|
||||||
|
mask = pygame.mask.from_surface(selection)
|
||||||
|
mask_view = mask.to_surface()
|
||||||
|
|
||||||
|
result = mask.to_surface(setsurface=image, unsetcolor=(0, 0, 0, 0))
|
||||||
|
|
||||||
|
|
||||||
|
while running:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
running = False
|
||||||
|
|
||||||
|
screen.fill("grey")
|
||||||
|
|
||||||
|
screen.blit(image, (260, 260))
|
||||||
|
screen.blit(mask_view, (540, 260))
|
||||||
|
screen.blit(result, (820, 260))
|
||||||
|
|
||||||
|
pygame.display.flip()
|
||||||
|
clock.tick(60)
|
||||||
|
|
||||||
|
pygame.quit()
|
||||||
Loading…
Reference in a new issue