#32 完了
このコミットが含まれているのは:
@@ -103,9 +103,9 @@ class Bg:
|
|||||||
self,
|
self,
|
||||||
game: Game,
|
game: Game,
|
||||||
):
|
):
|
||||||
self.base = BgBase (game)
|
|
||||||
self.jojoko = Jojoko (game)
|
|
||||||
self.kita = KitaSun (game)
|
self.kita = KitaSun (game)
|
||||||
|
self.base = BgBase (game, self.kita.sun, layer = self.kita.layer - 5)
|
||||||
|
self.jojoko = Jojoko (game)
|
||||||
self.grass = BgGrass (game)
|
self.grass = BgGrass (game)
|
||||||
|
|
||||||
|
|
||||||
@@ -284,23 +284,60 @@ class BgBase (GameObject):
|
|||||||
bg_evening: Surface
|
bg_evening: Surface
|
||||||
bg_grass: Surface
|
bg_grass: Surface
|
||||||
bg_night: Surface
|
bg_night: Surface
|
||||||
surface: Surface
|
sun: Sun
|
||||||
|
|
||||||
def __init__ (
|
def __init__ (
|
||||||
self,
|
self,
|
||||||
game: Game,
|
game: Game,
|
||||||
|
sun: Sun,
|
||||||
|
layer: float,
|
||||||
):
|
):
|
||||||
super ().__init__ (game)
|
super ().__init__ (game, layer = layer)
|
||||||
self.bg = pygame.image.load ('assets/bg.jpg')
|
self.bg = self._load_image ('assets/bg.jpg')
|
||||||
self.bg_evening = pygame.image.load ('assets/bg-evening.jpg')
|
self.bg_evening = self._load_image ('assets/bg-evening.jpg')
|
||||||
self.bg_grass = pygame.image.load ('assets/bg-grass.png')
|
self.bg_grass = self._load_image ('assets/bg-grass.png')
|
||||||
self.bg_night = pygame.image.load ('assets/bg-night.jpg')
|
self.bg_night = self._load_image ('assets/bg-night.jpg')
|
||||||
self.surface = pygame.transform.scale (self.bg, (CWindow.WIDTH, CWindow.HEIGHT))
|
self.sun = sun
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _load_image (
|
||||||
|
path: str,
|
||||||
|
) -> Surface:
|
||||||
|
return pygame.transform.scale (pygame.image.load (path),
|
||||||
|
(CWindow.WIDTH, CWindow.HEIGHT))
|
||||||
|
|
||||||
def redraw (
|
def redraw (
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.game.screen.blit (self.surface, (self.x, self.y))
|
date_tmp = self.game.sky.observer.date
|
||||||
|
self.game.sky.observer.date = self.game.now.date ()
|
||||||
|
sunrise_start: datetime = (
|
||||||
|
(ephem.localtime (self.game.sky.observer.previous_rising (self.sun))
|
||||||
|
- timedelta (minutes = 30)))
|
||||||
|
sunrise_end: datetime = sunrise_start + timedelta (hours = 1)
|
||||||
|
sunrise_centre: datetime = (
|
||||||
|
sunrise_start + (sunrise_end - sunrise_start) / 2)
|
||||||
|
sunset_start: datetime = (
|
||||||
|
(ephem.localtime (self.game.sky.observer.next_setting (self.sun))
|
||||||
|
- timedelta (minutes = 30)))
|
||||||
|
sunset_end: datetime = sunset_start + timedelta (hours = 1)
|
||||||
|
sunset_centre: datetime = (
|
||||||
|
sunset_start + (sunset_end - sunset_start) / 2)
|
||||||
|
self.game.sky.observer.date = date_tmp
|
||||||
|
surface: Surface = ((self.bg
|
||||||
|
if (sunrise_centre <= self.game.now < sunset_centre)
|
||||||
|
else self.bg_night)
|
||||||
|
.copy ())
|
||||||
|
if sunrise_start <= self.game.now < sunrise_end:
|
||||||
|
self.bg_evening.set_alpha (255 - int ((abs (self.game.now - sunrise_centre) * 510)
|
||||||
|
/ (sunrise_end - sunrise_centre)))
|
||||||
|
elif sunset_start <= self.game.now < sunset_end:
|
||||||
|
self.bg_evening.set_alpha (255 - int ((abs (self.game.now - sunset_centre) * 510)
|
||||||
|
/ (sunset_end - sunset_centre)))
|
||||||
|
else:
|
||||||
|
self.bg_evening.set_alpha (0)
|
||||||
|
surface.blit (self.bg_evening, (0, 0))
|
||||||
|
self.game.screen.blit (surface, (self.x, self.y))
|
||||||
super ().redraw ()
|
super ().redraw ()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする