diff --git a/learn_sql_model/game/game.py b/learn_sql_model/game/game.py index 5b14a17..13c844c 100644 --- a/learn_sql_model/game/game.py +++ b/learn_sql_model/game/game.py @@ -89,18 +89,12 @@ class Client: self.player.render() light_level = 0 self.darkness.fill((light_level, light_level, light_level)) - # self.darkness.blit( - # pygame.transform.smoothscale( - # self.spot, [self.light_power, self.light_power] - # ), - # (self.x - self.light_power / 2, self.y - self.light_power / 2), - # ) + self.light.render() self.screen.blit( pygame.transform.scale(self.darkness, self.screen.get_size()).convert(), (0, 0), special_flags=pygame.BLEND_MULT, ) - self.light.render() # update the screen self.menu.render() diff --git a/learn_sql_model/game/light.py b/learn_sql_model/game/light.py index 43ec4d1..b5ee42c 100644 --- a/learn_sql_model/game/light.py +++ b/learn_sql_model/game/light.py @@ -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): diff --git a/learn_sql_model/game/player.py b/learn_sql_model/game/player.py index 0f2f702..8f55990 100644 --- a/learn_sql_model/game/player.py +++ b/learn_sql_model/game/player.py @@ -30,8 +30,8 @@ class Player: self.white = (255, 255, 255) self.x = self.game.screen.get_width() / 2 self.y = self.game.screen.get_height() / 2 - self.speed = 5 - self.max_speed = 5 + self.speed = 10 + self.max_speed = 10 self.image = pygame.image.load("player.png").convert_alpha() self.x_last = self.x self.y_last = self.y