From 174ecc6c98efdbece67361d2b5bbb47b321096a6 Mon Sep 17 00:00:00 2001 From: Vlad <89295404+Virashu@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:40:54 +0300 Subject: [PATCH] Restructure project --- danmaku/{ => game}/animated.py | 2 +- danmaku/{ => game}/background.py | 2 +- danmaku/{ => game}/bullet.py | 54 ++--- danmaku/{ => game}/drop.py | 2 +- danmaku/{ => game}/enemy.py | 218 +++++++++--------- danmaku/{ => game}/entity.py | 2 +- danmaku/{ => game}/game.py | 14 +- danmaku/{ => game}/gameobject.py | 98 ++++---- danmaku/{ => game}/level.py | 2 +- danmaku/{ => game}/pause.py | 0 danmaku/{ => game}/player.py | 368 +++++++++++++++---------------- danmaku/{ => game}/shooter.py | 4 +- danmaku/main.py | 8 +- danmaku/{ => ui}/button.py | 0 danmaku/{ => ui}/history.py | 0 danmaku/{ => ui}/menu.py | 2 +- danmaku/{ => ui}/settings.py | 2 +- 17 files changed, 389 insertions(+), 389 deletions(-) rename danmaku/{ => game}/animated.py (97%) rename danmaku/{ => game}/background.py (94%) rename danmaku/{ => game}/bullet.py (92%) rename danmaku/{ => game}/drop.py (94%) rename danmaku/{ => game}/enemy.py (93%) rename danmaku/{ => game}/entity.py (93%) rename danmaku/{ => game}/game.py (97%) rename danmaku/{ => game}/gameobject.py (96%) rename danmaku/{ => game}/level.py (98%) rename danmaku/{ => game}/pause.py (100%) rename danmaku/{ => game}/player.py (94%) rename danmaku/{ => game}/shooter.py (96%) rename danmaku/{ => ui}/button.py (100%) rename danmaku/{ => ui}/history.py (100%) rename danmaku/{ => ui}/menu.py (98%) rename danmaku/{ => ui}/settings.py (98%) diff --git a/danmaku/animated.py b/danmaku/game/animated.py similarity index 97% rename from danmaku/animated.py rename to danmaku/game/animated.py index 1d2182d..e1eb79f 100644 --- a/danmaku/animated.py +++ b/danmaku/game/animated.py @@ -2,7 +2,7 @@ import pygame -from danmaku.gameobject import GameObject +from danmaku.game.gameobject import GameObject class Animated(GameObject): diff --git a/danmaku/background.py b/danmaku/game/background.py similarity index 94% rename from danmaku/background.py rename to danmaku/game/background.py index 29c6d92..e8f23e4 100644 --- a/danmaku/background.py +++ b/danmaku/game/background.py @@ -2,7 +2,7 @@ import vgame -from danmaku.animated import Animated +from danmaku.game.animated import Animated class Background(Animated): diff --git a/danmaku/bullet.py b/danmaku/game/bullet.py similarity index 92% rename from danmaku/bullet.py rename to danmaku/game/bullet.py index 95e50c4..0e9742b 100644 --- a/danmaku/bullet.py +++ b/danmaku/game/bullet.py @@ -1,27 +1,27 @@ -"""Entity's bullet declaration.""" - -from danmaku.entity import Entity -from danmaku.database import get_bullet_type - - -class Bullet(Entity): - """Bullet object.""" - - def __init__( - self, xy: tuple[int | float, int | float], damage: int | float, object_type - ): - args = get_bullet_type(object_type) - super().__init__( - xy, - (args["texture_size"][0], args["texture_size"][1]), - args["speed"], - 0, - damage, - ) - self.enemy = args["enemy"] - self.vx, self.vy = args["vx_vy"] - self.hitbox_radius = args["hitbox_radius"] - - self.texture_file = args["texture_file"] - self.texture_size = args["texture_size"] - self.my_type = object_type +"""Entity's bullet declaration.""" + +from danmaku.game.entity import Entity +from danmaku.database import get_bullet_type + + +class Bullet(Entity): + """Bullet object.""" + + def __init__( + self, xy: tuple[int | float, int | float], damage: int | float, object_type + ): + args = get_bullet_type(object_type) + super().__init__( + xy, + (args["texture_size"][0], args["texture_size"][1]), + args["speed"], + 0, + damage, + ) + self.enemy = args["enemy"] + self.vx, self.vy = args["vx_vy"] + self.hitbox_radius = args["hitbox_radius"] + + self.texture_file = args["texture_file"] + self.texture_size = args["texture_size"] + self.my_type = object_type diff --git a/danmaku/drop.py b/danmaku/game/drop.py similarity index 94% rename from danmaku/drop.py rename to danmaku/game/drop.py index 6796b5a..2a2bd93 100644 --- a/danmaku/drop.py +++ b/danmaku/game/drop.py @@ -1,6 +1,6 @@ """Entity's bullet declaration.""" -from danmaku.gameobject import GameObject +from danmaku.game.gameobject import GameObject # from danmaku.database import ... diff --git a/danmaku/enemy.py b/danmaku/game/enemy.py similarity index 93% rename from danmaku/enemy.py rename to danmaku/game/enemy.py index 762c8cb..7cdd51e 100644 --- a/danmaku/enemy.py +++ b/danmaku/game/enemy.py @@ -1,109 +1,109 @@ -"""Enemy object declaration.""" - -from random import randint, choices -from math import sin, cos, pi - -from danmaku.animated import Animated -from danmaku.bullet import Bullet -from danmaku.database import get_enemy_type -from danmaku.shooter import Shooter -from danmaku.drop import PowerUp, Points - - -class Enemy(Shooter, Animated): - """Enemy object.""" - - def __init__( - self, - xy: tuple[int | float, int | float], - object_type: str, - start_hp: int | float = 0, - ): - args = get_enemy_type(object_type) - - health = start_hp or args["hp"] - - super().__init__( - xy, - args["texture_size"], - args["speed"], - health, - args["dm"], - args["endurance"], - "basic enemy bullet", - 0, - args["shoot_v"] / 1000, - hitbox_radius=args["texture_size"][0] // 2, - direction=(0, 1), - ) - - frames = list(map(lambda x: f"/enemy/{x}", args["texture_file"].split(";"))) - Animated.__init__( - self, xy, args["texture_size"], args["speed"], frames, 0, period=0.1 - ) - self.texture_size = args["texture_size"] - self.my_type = object_type - self.cost = args["cost"] - - self.vx, self.vy = 0, 1 - - def shoot(self) -> list[Bullet]: - if self.can_shoot(): - match self.my_type: - case "boss": - if randint(0, 6) == 0: - return self.shoot_cluster() - return self.shoot_radial(waves=2, base_angle=randint(0, 359)) - case "basic enemy": - bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) - bullet.vx = randint(-100, 100) / 100 - bullet.vy = (1 - bullet.vx**2) ** 0.5 - return [bullet] - case "strong enemy": - return self.shoot_radial(waves=3, n=5, base_angle=randint(0, 359)) - return [] - - def shoot_radial(self, base_angle=0, angle_step=0, waves=1, n=6) -> list[Bullet]: - """Shoot circle of bullets""" - - bullets = [] - - for wave in range(waves): - first_angle = base_angle + wave * angle_step - for add_angle in range(0, 360, 360 // n): - angle = pi * ((first_angle + add_angle) % 360) / 180 - bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) - bullet.vx = cos(angle) - bullet.vy = sin(angle) - for _ in range(wave): - bullet.update(0.3) - bullets.append(bullet) - return bullets - - def shoot_cluster(self, waves=1, n=10, base_angle=0, arc=180): - bullets = [] - for wave in range(waves): - for i, a in enumerate(range(0, arc, arc // n)): - angle = pi * ((base_angle + a) % 360) / 180 - bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) - bullet.vx = cos(angle) * (i + 1) * 0.2 - bullet.vy = sin(angle) * (i + 1) * 0.2 - for _ in range(wave): - bullet.update(0.3) - bullets.append(bullet) - return bullets - - def generate_drops(self) -> list: - drops = [] - count = 1 - if self.my_type == "boss": - count = 5 - for _ in range(count): - pos = (self.x + randint(-10, 10), self.y + randint(-10, 10)) - match choices(("powerup", "points", None), (1, 1, 2))[0]: - case "powerup": - drops.append(PowerUp(pos)) - case "points": - drops.append(Points(pos)) - - return drops +"""Enemy object declaration.""" + +from random import randint, choices +from math import sin, cos, pi + +from danmaku.game.animated import Animated +from danmaku.game.bullet import Bullet +from danmaku.database import get_enemy_type +from danmaku.game.shooter import Shooter +from danmaku.game.drop import PowerUp, Points + + +class Enemy(Shooter, Animated): + """Enemy object.""" + + def __init__( + self, + xy: tuple[int | float, int | float], + object_type: str, + start_hp: int | float = 0, + ): + args = get_enemy_type(object_type) + + health = start_hp or args["hp"] + + super().__init__( + xy, + args["texture_size"], + args["speed"], + health, + args["dm"], + args["endurance"], + "basic enemy bullet", + 0, + args["shoot_v"] / 1000, + hitbox_radius=args["texture_size"][0] // 2, + direction=(0, 1), + ) + + frames = list(map(lambda x: f"/enemy/{x}", args["texture_file"].split(";"))) + Animated.__init__( + self, xy, args["texture_size"], args["speed"], frames, 0, period=0.1 + ) + self.texture_size = args["texture_size"] + self.my_type = object_type + self.cost = args["cost"] + + self.vx, self.vy = 0, 1 + + def shoot(self) -> list[Bullet]: + if self.can_shoot(): + match self.my_type: + case "boss": + if randint(0, 6) == 0: + return self.shoot_cluster() + return self.shoot_radial(waves=2, base_angle=randint(0, 359)) + case "basic enemy": + bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) + bullet.vx = randint(-100, 100) / 100 + bullet.vy = (1 - bullet.vx**2) ** 0.5 + return [bullet] + case "strong enemy": + return self.shoot_radial(waves=3, n=5, base_angle=randint(0, 359)) + return [] + + def shoot_radial(self, base_angle=0, angle_step=0, waves=1, n=6) -> list[Bullet]: + """Shoot circle of bullets""" + + bullets = [] + + for wave in range(waves): + first_angle = base_angle + wave * angle_step + for add_angle in range(0, 360, 360 // n): + angle = pi * ((first_angle + add_angle) % 360) / 180 + bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) + bullet.vx = cos(angle) + bullet.vy = sin(angle) + for _ in range(wave): + bullet.update(0.3) + bullets.append(bullet) + return bullets + + def shoot_cluster(self, waves=1, n=10, base_angle=0, arc=180): + bullets = [] + for wave in range(waves): + for i, a in enumerate(range(0, arc, arc // n)): + angle = pi * ((base_angle + a) % 360) / 180 + bullet = Bullet((self.x, self.y), self.damage, self.bullet_type) + bullet.vx = cos(angle) * (i + 1) * 0.2 + bullet.vy = sin(angle) * (i + 1) * 0.2 + for _ in range(wave): + bullet.update(0.3) + bullets.append(bullet) + return bullets + + def generate_drops(self) -> list: + drops = [] + count = 1 + if self.my_type == "boss": + count = 5 + for _ in range(count): + pos = (self.x + randint(-10, 10), self.y + randint(-10, 10)) + match choices(("powerup", "points", None), (1, 1, 2))[0]: + case "powerup": + drops.append(PowerUp(pos)) + case "points": + drops.append(Points(pos)) + + return drops diff --git a/danmaku/entity.py b/danmaku/game/entity.py similarity index 93% rename from danmaku/entity.py rename to danmaku/game/entity.py index 629af96..991cd0a 100644 --- a/danmaku/entity.py +++ b/danmaku/game/entity.py @@ -1,6 +1,6 @@ """Base class for alive objects""" -from danmaku.gameobject import GameObject +from danmaku.game.gameobject import GameObject class Entity(GameObject): diff --git a/danmaku/game.py b/danmaku/game/game.py similarity index 97% rename from danmaku/game.py rename to danmaku/game/game.py index b02b562..d41880c 100644 --- a/danmaku/game.py +++ b/danmaku/game/game.py @@ -5,9 +5,9 @@ import pygame from danmaku.utils import not_in_border, resource_path -from danmaku.enemy import Enemy -from danmaku.player import Player -from danmaku.bullet import Bullet +from danmaku.game.enemy import Enemy +from danmaku.game.player import Player +from danmaku.game.bullet import Bullet from danmaku.database import ( get_saved_objects, get_saved_game, @@ -16,10 +16,10 @@ delete_saved_objects, get_settings, ) -from danmaku.pause import Pause -from danmaku.background import Background -from danmaku.drop import Drop, PowerUp, Points -from danmaku.level import Level, Stage, BossStage +from danmaku.game.pause import Pause +from danmaku.game.background import Background +from danmaku.game.drop import Drop, PowerUp, Points +from danmaku.game.level import Level, Stage, BossStage # pylint: disable=attribute-defined-outside-init, missing-class-docstring diff --git a/danmaku/gameobject.py b/danmaku/game/gameobject.py similarity index 96% rename from danmaku/gameobject.py rename to danmaku/game/gameobject.py index 211fdff..114d7a4 100644 --- a/danmaku/gameobject.py +++ b/danmaku/game/gameobject.py @@ -1,49 +1,49 @@ -"""Base game object.""" - -import math - -from vgame.graphics import Graphics, Sprite - - -class GameObject(Sprite): - """ - A base game entity object. - """ - - hitbox_radius: int - - def __init__( - self, - xy: tuple[int | float, int | float], - width_height: tuple[int | float, int | float], - speed: int | float = 0, - hitbox_radius: int = 0, - direction: tuple[int | float, int | float] = (0, 0), - ): - super().__init__() - self.x, self.y = xy - self.speed = speed - self.width, self.height = width_height - self.vx, self.vy = direction - self.hitbox_radius = hitbox_radius - - def update(self, delta: int | float): - self.x += self.vx * delta * self.speed - self.y += self.vy * delta * self.speed - - self.rect.centerx, self.rect.centery, self.rect.w, self.rect.h = ( - int(self.x), - int(self.y), - int(self.width), - int(self.height), - ) - - def collision(self, other) -> bool: - """Check collision.""" - return ( - math.hypot(self.x - other.x, self.y - other.y) - < self.hitbox_radius + other.hitbox_radius - ) - - def draw(self, graphics: Graphics): - graphics.draw_sprite(self) +"""Base game object.""" + +import math + +from vgame.graphics import Graphics, Sprite + + +class GameObject(Sprite): + """ + A base game entity object. + """ + + hitbox_radius: int + + def __init__( + self, + xy: tuple[int | float, int | float], + width_height: tuple[int | float, int | float], + speed: int | float = 0, + hitbox_radius: int = 0, + direction: tuple[int | float, int | float] = (0, 0), + ): + super().__init__() + self.x, self.y = xy + self.speed = speed + self.width, self.height = width_height + self.vx, self.vy = direction + self.hitbox_radius = hitbox_radius + + def update(self, delta: int | float): + self.x += self.vx * delta * self.speed + self.y += self.vy * delta * self.speed + + self.rect.centerx, self.rect.centery, self.rect.w, self.rect.h = ( + int(self.x), + int(self.y), + int(self.width), + int(self.height), + ) + + def collision(self, other) -> bool: + """Check collision.""" + return ( + math.hypot(self.x - other.x, self.y - other.y) + < self.hitbox_radius + other.hitbox_radius + ) + + def draw(self, graphics: Graphics): + graphics.draw_sprite(self) diff --git a/danmaku/level.py b/danmaku/game/level.py similarity index 98% rename from danmaku/level.py rename to danmaku/game/level.py index cde1941..bb78bfc 100644 --- a/danmaku/level.py +++ b/danmaku/game/level.py @@ -8,7 +8,7 @@ import pygame -from danmaku.enemy import Enemy +from danmaku.game.enemy import Enemy class Stage: diff --git a/danmaku/pause.py b/danmaku/game/pause.py similarity index 100% rename from danmaku/pause.py rename to danmaku/game/pause.py diff --git a/danmaku/player.py b/danmaku/game/player.py similarity index 94% rename from danmaku/player.py rename to danmaku/game/player.py index b3c148e..9309bd7 100644 --- a/danmaku/player.py +++ b/danmaku/game/player.py @@ -1,184 +1,184 @@ -"""Player object declaration.""" - -import math -import vgame -from danmaku.bullet import Bullet -from danmaku.database import get_player_type -from danmaku.utils import constrain, Direction -from danmaku.shooter import Shooter -from danmaku.animated import Animated - - -class Player(Shooter, Animated): - """Player object.""" - - def __init__( - self, - xy: tuple[int | float, int | float], - object_type: str, - bombs=0, - lives=1, - updated_hp=0, - ) -> None: - args = get_player_type(object_type) - - health = updated_hp or args["hp"] * lives - - super().__init__( - xy, - args["texture_size"], - args["speed"], - health, - args["dm"], - args["endurance"], - "basic player bullet", - 0, - args["shoot_v"] / 1000, - ) - - # Animation - files = args["texture_file"].split(";") - self.animation_frames = { - Direction.LEFT: [], - Direction.RIGHT: [], - Direction.UP: [], - Direction.DOWN: [], - } - - for i in files: - path = f"/player/{i}" - if "left" in i: - self.animation_frames[Direction.LEFT].append(path) - if "right" in i: - self.animation_frames[Direction.RIGHT].append(path) - if "up" in i: - self.animation_frames[Direction.UP].append(path) - if "down" in i: - self.animation_frames[Direction.DOWN].append(path) - - Animated.__init__( - self, xy, args["texture_size"], args["speed"], [], 0, period=0.1 - ) - - self.texture_file = self.animation_frames[Direction.LEFT][ - self.animation_current - ] - self.texture_size = args["texture_size"] - - self.my_type = object_type - self.score: int = 0 - self.power: int = 1 - self.bombs = bombs - - self.hitbox_radius = args["hitbox_radius"] - self.slow = False - - # Bounds - self.left = self.top = 0 - self.right = self.bottom = 10e6 - - def shoot(self) -> list[Bullet]: - res: list[Bullet] = [] - - if self.can_shoot(): - - bullet = Bullet( - (self.x, self.y), - self.damage + self.power, - self.bullet_type, - ) - - res.append(bullet) - - if self.power > 4: - vx = math.cos(math.pi * 85 / 180) - vy = -math.sin(math.pi * 85 / 180) - - b1 = Bullet( - (self.x, self.y), - self.damage + self.power, - self.bullet_type, - ) - b2 = Bullet( - (self.x, self.y), - self.damage + self.power, - self.bullet_type, - ) - b1.vx = vx - b2.vx = -vx - b1.vy = b2.vy = vy - res.extend([b1, b2]) - - return res - - def bomb(self) -> list[Bullet]: - """Spawn bomb, AKA super-bullet""" - res: list[Bullet] = [] - if self.bombs != 0: - if self.can_shoot(): - bullet = Bullet( - (self.x, self.y), - self.damage + self.power + 50, - "player bomb", - ) - res.append(bullet) - self.bombs -= 1 - return res - - def set_bounds( - self, - left: int | float, - top: int | float, - right: int | float, - bottom: int | float, - ) -> None: - """Set movement bounds""" - self.left = left - self.top = top - self.right = right - self.bottom = bottom - - def update(self, delta: int | float) -> None: - speed = self.speed if not self.slow else self.speed * 0.5 - - self.x += self.vx * delta * speed - self.x = constrain( - self.x, self.left + self.width / 2, self.right - self.width / 2 - ) - - self.y += self.vy * delta * speed - self.y = constrain( - self.y, self.top + self.height / 2, self.bottom - self.height / 2 - ) - - self.rect.centerx, self.rect.centery, self.rect.w, self.rect.h = ( - int(self.x), - int(self.y), - int(self.width), - int(self.height), - ) - - def animate(self) -> None: - """Animate one frame.""" - if self.can_animate(): - direction = None - if self.vx > 0: - direction = Direction.RIGHT - elif self.vy > 0: - direction = Direction.DOWN - elif self.vx < 0: - direction = Direction.LEFT - elif self.vy < 0: - direction = Direction.UP - if direction is not None: - self.animation_current = (self.animation_current + 1) % len( - self.animation_frames[direction] - ) - self.texture_file = self.animation_frames[direction][ - self.animation_current - ] - - def draw(self, graphics: vgame.graphics.Graphics) -> None: - graphics.draw_sprite(self) - if self.slow: - graphics.circle((self.x, self.y), self.hitbox_radius, (200, 0, 200)) +"""Player object declaration.""" + +import math +import vgame +from danmaku.game.bullet import Bullet +from danmaku.database import get_player_type +from danmaku.utils import constrain, Direction +from danmaku.game.shooter import Shooter +from danmaku.game.animated import Animated + + +class Player(Shooter, Animated): + """Player object.""" + + def __init__( + self, + xy: tuple[int | float, int | float], + object_type: str, + bombs=0, + lives=1, + updated_hp=0, + ) -> None: + args = get_player_type(object_type) + + health = updated_hp or args["hp"] * lives + + super().__init__( + xy, + args["texture_size"], + args["speed"], + health, + args["dm"], + args["endurance"], + "basic player bullet", + 0, + args["shoot_v"] / 1000, + ) + + # Animation + files = args["texture_file"].split(";") + self.animation_frames = { + Direction.LEFT: [], + Direction.RIGHT: [], + Direction.UP: [], + Direction.DOWN: [], + } + + for i in files: + path = f"/player/{i}" + if "left" in i: + self.animation_frames[Direction.LEFT].append(path) + if "right" in i: + self.animation_frames[Direction.RIGHT].append(path) + if "up" in i: + self.animation_frames[Direction.UP].append(path) + if "down" in i: + self.animation_frames[Direction.DOWN].append(path) + + Animated.__init__( + self, xy, args["texture_size"], args["speed"], [], 0, period=0.1 + ) + + self.texture_file = self.animation_frames[Direction.LEFT][ + self.animation_current + ] + self.texture_size = args["texture_size"] + + self.my_type = object_type + self.score: int = 0 + self.power: int = 1 + self.bombs = bombs + + self.hitbox_radius = args["hitbox_radius"] + self.slow = False + + # Bounds + self.left = self.top = 0 + self.right = self.bottom = 10e6 + + def shoot(self) -> list[Bullet]: + res: list[Bullet] = [] + + if self.can_shoot(): + + bullet = Bullet( + (self.x, self.y), + self.damage + self.power, + self.bullet_type, + ) + + res.append(bullet) + + if self.power > 4: + vx = math.cos(math.pi * 85 / 180) + vy = -math.sin(math.pi * 85 / 180) + + b1 = Bullet( + (self.x, self.y), + self.damage + self.power, + self.bullet_type, + ) + b2 = Bullet( + (self.x, self.y), + self.damage + self.power, + self.bullet_type, + ) + b1.vx = vx + b2.vx = -vx + b1.vy = b2.vy = vy + res.extend([b1, b2]) + + return res + + def bomb(self) -> list[Bullet]: + """Spawn bomb, AKA super-bullet""" + res: list[Bullet] = [] + if self.bombs != 0: + if self.can_shoot(): + bullet = Bullet( + (self.x, self.y), + self.damage + self.power + 50, + "player bomb", + ) + res.append(bullet) + self.bombs -= 1 + return res + + def set_bounds( + self, + left: int | float, + top: int | float, + right: int | float, + bottom: int | float, + ) -> None: + """Set movement bounds""" + self.left = left + self.top = top + self.right = right + self.bottom = bottom + + def update(self, delta: int | float) -> None: + speed = self.speed if not self.slow else self.speed * 0.5 + + self.x += self.vx * delta * speed + self.x = constrain( + self.x, self.left + self.width / 2, self.right - self.width / 2 + ) + + self.y += self.vy * delta * speed + self.y = constrain( + self.y, self.top + self.height / 2, self.bottom - self.height / 2 + ) + + self.rect.centerx, self.rect.centery, self.rect.w, self.rect.h = ( + int(self.x), + int(self.y), + int(self.width), + int(self.height), + ) + + def animate(self) -> None: + """Animate one frame.""" + if self.can_animate(): + direction = None + if self.vx > 0: + direction = Direction.RIGHT + elif self.vy > 0: + direction = Direction.DOWN + elif self.vx < 0: + direction = Direction.LEFT + elif self.vy < 0: + direction = Direction.UP + if direction is not None: + self.animation_current = (self.animation_current + 1) % len( + self.animation_frames[direction] + ) + self.texture_file = self.animation_frames[direction][ + self.animation_current + ] + + def draw(self, graphics: vgame.graphics.Graphics) -> None: + graphics.draw_sprite(self) + if self.slow: + graphics.circle((self.x, self.y), self.hitbox_radius, (200, 0, 200)) diff --git a/danmaku/shooter.py b/danmaku/game/shooter.py similarity index 96% rename from danmaku/shooter.py rename to danmaku/game/shooter.py index 48ea645..24f6c38 100644 --- a/danmaku/shooter.py +++ b/danmaku/game/shooter.py @@ -4,8 +4,8 @@ import pygame -from danmaku.entity import Entity -from danmaku.bullet import Bullet +from danmaku.game.entity import Entity +from danmaku.game.bullet import Bullet class Shooter(Entity): diff --git a/danmaku/main.py b/danmaku/main.py index 1ea2cb6..6b00f9d 100644 --- a/danmaku/main.py +++ b/danmaku/main.py @@ -2,10 +2,10 @@ from vgame import Runner -from danmaku.menu import Menu -from danmaku.game import Game -from danmaku.history import History -from danmaku.settings import Settings +from danmaku.ui.menu import Menu +from danmaku.game.game import Game +from danmaku.ui.history import History +from danmaku.ui.settings import Settings WIDTH, HEIGHT = 500, 500 TICKRATE = 120 diff --git a/danmaku/button.py b/danmaku/ui/button.py similarity index 100% rename from danmaku/button.py rename to danmaku/ui/button.py diff --git a/danmaku/history.py b/danmaku/ui/history.py similarity index 100% rename from danmaku/history.py rename to danmaku/ui/history.py diff --git a/danmaku/menu.py b/danmaku/ui/menu.py similarity index 98% rename from danmaku/menu.py rename to danmaku/ui/menu.py index 91b4ade..bfe534c 100644 --- a/danmaku/menu.py +++ b/danmaku/ui/menu.py @@ -4,7 +4,7 @@ import vgame from danmaku.database import get_saved_objects -from danmaku.button import Button, Cursor +from danmaku.ui.button import Button, Cursor from danmaku.utils import resource_path diff --git a/danmaku/settings.py b/danmaku/ui/settings.py similarity index 98% rename from danmaku/settings.py rename to danmaku/ui/settings.py index 3935dd7..df2108a 100644 --- a/danmaku/settings.py +++ b/danmaku/ui/settings.py @@ -4,7 +4,7 @@ from danmaku.database import get_settings -from danmaku.button import SettingsValue, Button +from danmaku.ui.button import SettingsValue, Button from danmaku.database.database import set_settings