diff --git a/src/doggo/assets/landscape/00.png b/src/doggo/assets/landscape/00.png new file mode 100644 index 0000000..73ea678 Binary files /dev/null and b/src/doggo/assets/landscape/00.png differ diff --git a/src/doggo/assets/landscape/00_bg.png b/src/doggo/assets/landscape/00_bg.png deleted file mode 100644 index 3b54bc6..0000000 Binary files a/src/doggo/assets/landscape/00_bg.png and /dev/null differ diff --git a/src/doggo/assets/landscape/00_fg.png b/src/doggo/assets/landscape/00_fg.png deleted file mode 100644 index f4c6813..0000000 Binary files a/src/doggo/assets/landscape/00_fg.png and /dev/null differ diff --git a/src/doggo/landscape.py b/src/doggo/landscape.py index 62158f2..d0251a1 100644 --- a/src/doggo/landscape.py +++ b/src/doggo/landscape.py @@ -9,6 +9,7 @@ from loguru import logger from doggo import ASSETS_PATH +from doggo.dog.body import SpriteSheet class Biome(IntEnum): @@ -28,11 +29,8 @@ def random(cls) -> Biome: class LandscapeLayer: """A layer of the landscape.""" - path = ASSETS_PATH.joinpath("landscape") - - def __init__(self, image: str, topleft: tuple[int, int] = (0, 0)) -> None: - image_path = self.path.joinpath(image) - self.image = pg.image.load(image_path).convert_alpha() + def __init__(self, image: pg.Surface, topleft: tuple[int, int] = (0, 0)) -> None: + self.image = image self.rect = self.image.get_rect(topleft=topleft) def draw(self, screen: pg.Surface) -> None: @@ -43,9 +41,11 @@ def draw(self, screen: pg.Surface) -> None: class Landscape: """The landscape of the game.""" - bg_suffix = "_bg.png" - fg_suffix = "_fg.png" + path = ASSETS_PATH.joinpath("landscape") def __init__(self, biome: Biome) -> None: - self.background = LandscapeLayer(image=f"{biome:02d}{self.bg_suffix}") - self.foreground = LandscapeLayer(image=f"{biome:02d}{self.fg_suffix}") + asset_path = self.path.joinpath(f"{biome:02d}.png") + sprite_sheet = SpriteSheet(path=asset_path, columns=1, rows=2) + + self.background = LandscapeLayer(image=sprite_sheet.get_sprite((0, 1))) + self.foreground = LandscapeLayer(image=sprite_sheet.get_sprite((0, 0))) diff --git a/src_assets/ground.aseprite b/src_assets/ground.aseprite deleted file mode 100644 index 0ddd6ba..0000000 Binary files a/src_assets/ground.aseprite and /dev/null differ diff --git a/tests/test_landscape.py b/tests/test_landscape.py index c561582..7b0093d 100644 --- a/tests/test_landscape.py +++ b/tests/test_landscape.py @@ -1,5 +1,7 @@ from __future__ import annotations +import pygame as pg + from doggo.landscape import Biome from doggo.landscape import LandscapeLayer @@ -12,7 +14,7 @@ def test_get_random_biome(): def test_landscape_layer_draw_on_screen(pg_screen_mock): - image = f"{Biome.MOUNTAIN:02d}_bg.png" + image = pg.Surface((100, 100)) landscape_layer = LandscapeLayer(image=image, topleft=(10, 10)) landscape_layer.draw(pg_screen_mock)