From 7db07c7d35235ffbd673cff81772c0283e9d52e0 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 20 Jun 2023 19:27:55 -0500 Subject: [PATCH] wip --- learn_sql_model/game/game.py | 3 +++ learn_sql_model/game/light.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 learn_sql_model/game/light.py diff --git a/learn_sql_model/game/game.py b/learn_sql_model/game/game.py index f409c22..aea1c26 100644 --- a/learn_sql_model/game/game.py +++ b/learn_sql_model/game/game.py @@ -8,6 +8,7 @@ from learn_sql_model.console import console from learn_sql_model.game.map import Map from learn_sql_model.game.menu import Menu from learn_sql_model.game.player import Player +from learn_sql_model.game.light import Light from learn_sql_model.optional import _optional_import_ pygame = _optional_import_("pygame", group="game") @@ -33,6 +34,7 @@ class Client: self.player = Player(self) self.menu = Menu(self) self.map = Map(self) + self.light = Light(self) self.font = pygame.font.SysFont("", 50) self.joysticks = {} @@ -78,6 +80,7 @@ class Client: self.screen.fill((0, 0, 0)) self.map.render() self.player.render() + 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 new file mode 100644 index 0000000..ebbf1c4 --- /dev/null +++ b/learn_sql_model/game/light.py @@ -0,0 +1,23 @@ +from learn_sql_model.console import console +from learn_sql_model.optional import _optional_import_ + +pygame = _optional_import_("pygame", group="game") + +class Light: + def __init__(self, game): + self.game = game + + def render(self): + mx, my = pygame.mouse.get_pos() + v = pygame.math.Vector2(mx - self.game.player.hero.x, my - self.game.player.hero.y) + v.scale_to_length(1000) + + for r in range(0, 360): + _v = v.rotate(r) + pygame.draw.line( + self.game.screen, + (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), + 50 + )