This commit is contained in:
Waylon Walker 2023-06-30 07:57:40 -05:00
parent d0b3712f17
commit f66255ea0d
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
3 changed files with 14 additions and 12 deletions

View file

@ -6,7 +6,9 @@ pygame = _optional_import_("pygame", group="game")
class Light:
def __init__(self, game):
self.game = game
self.surf = pygame.Surface((1000, 100))
self.surf = pygame.Surface(
(self.game.screen.get_width(), self.game.screen.get_height())
)
# pil_image = Image.new("RGBA", (1000, 500))
# pil_draw = ImageDraw.Draw(pil_image)
# pil_draw.pieslice((-1500, -100, 1000, 600), 340, 20, fill=(255, 250, 205))
@ -29,6 +31,7 @@ class Light:
# )
def render(self):
self.surf.fill((0, 0, 0))
mx, my = pygame.mouse.get_pos()
v = pygame.math.Vector2(
mx - self.game.player.hero.x, my - self.game.player.hero.y
@ -43,7 +46,7 @@ class Light:
for r in range(-25, 25):
_v = v.rotate(r)
pygame.draw.line(
self.game.screen,
self.surf,
(255, 250, 205),
(self.game.player.hero.x, self.game.player.hero.y),
(self.game.player.hero.x + _v.x, self.game.player.hero.y + _v.y),
@ -51,12 +54,17 @@ class Light:
)
# draw a circle
pygame.draw.circle(
self.game.screen,
self.surf,
(255, 250, 205),
(self.game.player.hero.x, self.game.player.hero.y),
self.game.player.hero.lanturn_strength,
)
self.game.darkness.blit(
pygame.transform.scale(self.surf, self.game.screen.get_size()).convert(),
(0, 0),
)
def render_flashlight(light, strength, angle):