Browse Source

大月ヨヨコ爆誕

sicawke
みてるぞ 6 months ago
parent
commit
80d6c09967
2 changed files with 45 additions and 7 deletions
  1. +45
    -7
      main.py
  2. BIN
      moon.png

+ 45
- 7
main.py View File

@@ -10,6 +10,7 @@ from datetime import datetime, timedelta
import emoji
import ephem
import pygame
import pygame.gfxdraw
import pytchat
from playsound import playsound
from pygame.locals import *
@@ -91,7 +92,6 @@ class Main:
# 大月ヨヨコ
jojoko: pygame.Surface = pygame.transform.scale (
pygame.image.load ('moon.png'), (200, 200))
jojoko.set_colorkey (pygame.Color (0, 255, 0))

# 音声再生器の初期化
pygame.mixer.init (frequency = 44100)
@@ -166,7 +166,7 @@ class Main:
cls.draw_bg (screen, bg_day, bg_evening, bg_night, bg_grass,
kita, jojoko,
sunrise_start, sunrise_end, sunset_start, sunset_end,
sun_alt)
sun_alt, moon_alt, moon_days_old)

# 左上に時刻表示
for i in range (4):
@@ -296,7 +296,7 @@ class Main:
bg_grass, kita, jojoko,
sunrise_start, sunrise_end,
sunset_start, sunset_end,
sun_alt)
sun_alt, moon_alt, moon_days_old)

chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ',
'id': '',
@@ -333,14 +333,17 @@ class Main:
sunrise_end: datetime,
sunset_start: datetime,
sunset_end: datetime,
sun_alt: float) \
sun_alt: float,
moon_alt: float,
moon_days_old: float) \
-> None:
sunrise_centre: datetime = (
sunrise_start + (sunrise_end - sunrise_start) / 2)
sunset_centre: datetime = (
sunset_start + (sunset_end - sunset_start) / 2)

jojoko: pygame.Surface = jojoko_original.copy ()
jojoko: pygame.Surface = cls.get_jojoko (jojoko_original,
moon_days_old)

dt: datetime = datetime.now ()

@@ -358,10 +361,19 @@ class Main:
else:
bg_evening.set_alpha (0)

if sunrise_start <= dt < sunset_end:
jojoko.set_alpha (255 - 255 / 15 * abs (moon_days_old - 15))
else:
jojoko.set_alpha (255)

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

# TODO: 緑を塗ってヨヨコを缺かす.
# pygame.draw.arc (jojoko, (0, 255, 0),
if -10 <= moon_alt < 40:
y = ((CWindow.HEIGHT / 2 + 100)
- (CWindow.HEIGHT / 2 + 200) / 30 * moon_alt)
screen.blit (jojoko, jojoko.get_rect (center = (400, y)))

screen.blit (bg_grass, (0, 0))

if -10 <= sun_alt < 40:
y = ((CWindow.HEIGHT / 2 + 100)
@@ -370,6 +382,32 @@ class Main:

screen.blit (bg_grass, (0, 0))

@classmethod
def get_jojoko (
cls,
jojoko_original: pygame.Surface,
moon_days_old: float) \
-> pygame.Surface:
jojoko: pygame.Surface = jojoko_original.copy ()

jojoko.set_colorkey ((0, 255, 0))

for i in range (200):
if 1 <= moon_days_old < 7:
pygame.gfxdraw.bezier (jojoko, ((0, 100 + i), (100, 180 * moon_days_old / 7 - 80 + i), (200, 100 + i)), 3, (0, 255, 0))
elif moon_days_old < 14:
pygame.gfxdraw.bezier (jojoko, ((0, 100 + i), (100, 180 * moon_days_old / 7 - 80 + i), (200, 100 + i)), 3, (0, 255, 0))
elif moon_days_old < 15:
pass
elif moon_days_old < 22:
pygame.gfxdraw.bezier (jojoko, ((0, 100 - i), (100, 180 * (moon_days_old - 15) / 7 - 80 - i), (200, 100 - i)), 3, (0, 255, 0))
elif moon_days_old < 30:
pygame.gfxdraw.bezier (jojoko, ((0, 100 - i), (100, 180 * (moon_days_old - 15) / 7 - 80 - i), (200, 100 - i)), 3, (0, 255, 0))
else:
jojoko.fill ((0, 255, 0))

return jojoko


if __name__ == '__main__':
Main.main (sys.argv, len (sys.argv))


BIN
moon.png View File

Before After
Width: 2064  |  Height: 1785  |  Size: 728 KiB Width: 1329  |  Height: 1329  |  Size: 641 KiB

Loading…
Cancel
Save