From 2ba68d9e313ee1d6c8a030199acef509d3a86aae Mon Sep 17 00:00:00 2001 From: miteruzo Date: Tue, 17 Dec 2024 07:19:33 +0900 Subject: [PATCH] =?UTF-8?q?#31=20=E3=81=8D=E5=A4=AA=E3=81=8F=E9=99=BD?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index 24162a6..6b986a2 100644 --- a/test.py +++ b/test.py @@ -29,10 +29,8 @@ DEERJIKA_FONT = pygame.font.SysFont ('07nikumarufont', 50) def main ( ) -> None: game = Game () - bg = Bg (game) - KitaSun (game) - deerjika = Deerjika (game, DeerjikaPattern.RELAXED, - x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120) + Bg (game) + Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120) balloon = Balloon (game) CurrentTime (game, SYSTEM_FONT) try: @@ -47,6 +45,32 @@ def main ( game.redraw () +class Bg: + """ + 背景オブゼクト管理用クラス + + Attributes: + base (BgBase): 最背面 + grass (BgGrass): 草原部分 + jojoko (Jojoko): 大月ヨヨコ + kita (KitaSun): き太く陽 + """ + + base: BgBase + grass: BgGrass + jojoko: Jojoko + kita: KitaSun + + def __init__ ( + self, + game: Game, + ): + self.base = BgBase (game) + self.jojoko = Jojoko (game) + self.kita = KitaSun (game) + self.grass = BgGrass (game) + + class DeerjikaPattern (Enum): """ ニジカの状態 @@ -55,11 +79,13 @@ class DeerjikaPattern (Enum): NORMAL: 通常 RELAXED: 足パタパタ SLEEPING: 寝ニジカ + DANCING: ダンシング・ニジカ """ NORMAL = auto () RELAXED = auto () SLEEPING = auto () + DANCING = auto () class Direction (Enum): @@ -84,6 +110,7 @@ class Game: frame (int): フレーム・カウンタ redrawers (list[Redrawer]): 再描画するクラスのリスト screen (Surface): 基底スクリーン + sky (Sky): 天体情報 """ clock: Clock @@ -182,7 +209,7 @@ class GameObject: self.frame += 1 -class Bg (GameObject): +class BgBase (GameObject): """ 背景 @@ -207,6 +234,32 @@ class Bg (GameObject): super ().redraw () +class BgGrass (GameObject): + """ + 背景の草原部分 + + Attributes: + surface (Surface): 草原 Surface + """ + + surface: Surface + + def __init__ ( + self, + game: Game, + ): + super ().__init__ (game) + self.game = game + self.surface = pygame.image.load ('assets/bg-grass.png') + self.surface = pygame.transform.scale (self.surface, (CWindow.WIDTH, CWindow.HEIGHT)) + + def redraw ( + self, + ) -> None: + self.game.screen.blit (self.surface, (self.x, self.y)) + super ().redraw () + + class Deerjika (GameObject): """ 伊地知ニジカ @@ -436,6 +489,7 @@ class Jojoko (GameObject): def __init__ ( self, + game: Game, ): ...