Browse Source

本日作業分

sicawke
みてるぞ 6 months ago
parent
commit
37618c5df1
1 changed files with 33 additions and 26 deletions
  1. +33
    -26
      main.py

+ 33
- 26
main.py View File

@@ -91,6 +91,7 @@ class Main:
# 大月ヨヨコ # 大月ヨヨコ
jojoko: pygame.Surface = pygame.transform.scale ( jojoko: pygame.Surface = pygame.transform.scale (
pygame.image.load ('moon.png'), (200, 200)) pygame.image.load ('moon.png'), (200, 200))
jojoko.set_colorkey (pygame.Color (0, 255, 0))


# 音声再生器の初期化 # 音声再生器の初期化
pygame.mixer.init (frequency = 44100) pygame.mixer.init (frequency = 44100)
@@ -119,7 +120,7 @@ class Main:
# Youtube Chat から取得したコメントたち # Youtube Chat から取得したコメントたち
chat_items: list = [] chat_items: list = []


# 会話の履歴(3 件分保持)
# 会話の履歴
histories: list = [] histories: list = []


while (True): while (True):
@@ -142,24 +143,25 @@ class Main:
# 日の入終了 # 日の入終了
sunset_end: datetime = sunset_start + timedelta (hours = 1) sunset_end: datetime = sunset_start + timedelta (hours = 1)


# 月の出開始
'todo'

# 月の出終了
'todo'

# 月の入開始
'todo'

# 月の入終了
'todo'

# 日の角度
# 時刻つき観測地
observer_with_time: ephem.Observer = observer observer_with_time: ephem.Observer = observer
observer_with_time.date = datetime.now () - timedelta (hours = 9) observer_with_time.date = datetime.now () - timedelta (hours = 9)

# 日の角度
sun.compute (observer_with_time) sun.compute (observer_with_time)
sun_alt: float = CommonModule.rad_to_deg (sun.alt) sun_alt: float = CommonModule.rad_to_deg (sun.alt)


# 月の角度
moon.compute (observer_with_time)
moon_alt: float = CommonModule.rad_to_deg (moon.alt)

# 月齢
new_moon_dt: datetime = ephem.localtime (
ephem.previous_new_moon (observer_with_time.date))
moon_days_old: float = (
(datetime.now () - new_moon_dt).total_seconds ()
/ 60 / 60 / 24)

# 背景描画 # 背景描画
cls.draw_bg (screen, bg_day, bg_evening, bg_night, bg_grass, cls.draw_bg (screen, bg_day, bg_evening, bg_night, bg_grass,
kita, jojoko, kita, jojoko,
@@ -320,24 +322,26 @@ class Main:
@classmethod @classmethod
def draw_bg ( def draw_bg (
cls, cls,
screen: pygame.Surface,
bg_day: pygame.Surface,
bg_evening: pygame.Surface,
bg_night: pygame.Surface,
bg_grass: pygame.Surface,
kita: pygame.Surface,
jojoko: pygame.Surface,
sunrise_start: datetime,
sunrise_end: datetime,
sunset_start: datetime,
sunset_end: datetime,
sun_alt: float) \
screen: pygame.Surface,
bg_day: pygame.Surface,
bg_evening: pygame.Surface,
bg_night: pygame.Surface,
bg_grass: pygame.Surface,
kita: pygame.Surface,
jojoko_original: pygame.Surface,
sunrise_start: datetime,
sunrise_end: datetime,
sunset_start: datetime,
sunset_end: datetime,
sun_alt: float) \
-> None: -> None:
sunrise_centre: datetime = ( sunrise_centre: datetime = (
sunrise_start + (sunrise_end - sunrise_start) / 2) sunrise_start + (sunrise_end - sunrise_start) / 2)
sunset_centre: datetime = ( sunset_centre: datetime = (
sunset_start + (sunset_end - sunset_start) / 2) sunset_start + (sunset_end - sunset_start) / 2)


jojoko: pygame.Surface = jojoko_original.copy ()

dt: datetime = datetime.now () dt: datetime = datetime.now ()


if sunrise_centre <= dt < sunset_centre: if sunrise_centre <= dt < sunset_centre:
@@ -356,6 +360,9 @@ class Main:


screen.blit (bg_evening, (0, 0)) screen.blit (bg_evening, (0, 0))


# TODO: 緑を塗ってヨヨコを缺かす.
# pygame.draw.arc (jojoko, (0, 255, 0),

if -10 <= sun_alt < 40: if -10 <= sun_alt < 40:
y = ((CWindow.HEIGHT / 2 + 100) y = ((CWindow.HEIGHT / 2 + 100)
- (CWindow.HEIGHT / 2 + 200) / 30 * sun_alt) - (CWindow.HEIGHT / 2 + 200) / 30 * sun_alt)


Loading…
Cancel
Save