31 ヨヨコぼちぼち
このコミットが含まれているのは:
実行可能ファイル → ノーマルファイル
|
変更前 幅: | 高さ: | サイズ: 641 KiB 変更後 幅: | 高さ: | サイズ: 641 KiB |
@@ -7,7 +7,9 @@ from enum import Enum, auto
|
|||||||
from typing import Callable, TypedDict
|
from typing import Callable, TypedDict
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
import ephem # type: ignore
|
||||||
import pygame
|
import pygame
|
||||||
|
import pygame.gfxdraw
|
||||||
from cv2 import VideoCapture
|
from cv2 import VideoCapture
|
||||||
from ephem import Moon, Observer, Sun # type: ignore
|
from ephem import Moon, Observer, Sun # type: ignore
|
||||||
from pygame import Rect, Surface
|
from pygame import Rect, Surface
|
||||||
@@ -482,22 +484,50 @@ class Jojoko (GameObject):
|
|||||||
大月ヨヨコ
|
大月ヨヨコ
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
phase (float): 月齢
|
base (Surface): 満月ヨヨコ Surface
|
||||||
|
moon (Moon): ephem の月オブゼクト
|
||||||
|
surface (Surface): 缺けたヨヨコ Surface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
phase: float
|
base: Surface
|
||||||
|
moon: Moon
|
||||||
|
|
||||||
def __init__ (
|
def __init__ (
|
||||||
self,
|
self,
|
||||||
game: Game,
|
game: Game,
|
||||||
):
|
):
|
||||||
...
|
super ().__init__ (game)
|
||||||
|
self.base = pygame.transform.scale (pygame.image.load ('assets/moon.png'), (200, 200))
|
||||||
|
|
||||||
def redraw (
|
def redraw (
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def phase (
|
||||||
|
self,
|
||||||
|
) -> float:
|
||||||
|
dt: datetime = ephem.localtime (ephem.previous_new_moon (self.game.sky.observer.date))
|
||||||
|
return (datetime.now () - dt).total_seconds () / 60 / 60 / 24
|
||||||
|
|
||||||
|
@property
|
||||||
|
def surface (
|
||||||
|
self,
|
||||||
|
) -> Surface:
|
||||||
|
jojoko = self.base.copy ()
|
||||||
|
jojoko.set_colorkey ((0, 255, 0))
|
||||||
|
for i in range (200):
|
||||||
|
if 1 <= self.phase < 15:
|
||||||
|
pygame.gfxdraw.bezier (jojoko, ((0, 100 + i), (100, 180 * self.phase / 7 - 80 + i), (200, 100 + i)), 3, (0, 255, 0))
|
||||||
|
elif self.phase < 16:
|
||||||
|
pass
|
||||||
|
elif self.phase < 30:
|
||||||
|
pygame.gfxdraw.bezier (jojoko, ((0, 100 - i), (100, 180 * (self.phase - 15) / 7 - 80 - i), (200, 100 - i)), 3, (0, 255, 0))
|
||||||
|
else:
|
||||||
|
jojoko.fill ((0, 255, 0))
|
||||||
|
return jojoko
|
||||||
|
|
||||||
|
|
||||||
class Sky:
|
class Sky:
|
||||||
"""
|
"""
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする