2 コミット

作成者 SHA1 メッセージ 日付
みてるぞ 80d6c09967 大月ヨヨコ爆誕 2024-05-13 02:54:10 +09:00
みてるぞ 37618c5df1 本日作業分 2024-05-13 01:00:32 +09:00
3個のファイルの変更105行の追加56行の削除
+73 -32
ファイルの表示
@@ -10,6 +10,7 @@ from datetime import datetime, timedelta
import emoji import emoji
import ephem import ephem
import pygame import pygame
import pygame.gfxdraw
import pytchat import pytchat
from playsound import playsound from playsound import playsound
from pygame.locals import * from pygame.locals import *
@@ -18,7 +19,6 @@ from aques import Aques
from common_const import * from common_const import *
from common_module import CommonModule from common_module import CommonModule
from mode import Mode from mode import Mode
from othello import Othello
from talk import Talk from talk import Talk
from youtube import * from youtube import *
@@ -49,9 +49,6 @@ class Main:
screen: pygame.Surface = pygame.display.set_mode ( screen: pygame.Surface = pygame.display.set_mode (
(CWindow.WIDTH, CWindow.HEIGHT)) (CWindow.WIDTH, CWindow.HEIGHT))
# オセロ用オブジェクト
othello = Othello (screen)
# 大月ヨヨコの観測値 # 大月ヨヨコの観測値
observer = ephem.Observer () observer = ephem.Observer ()
observer.lat, observer.lon = '35', '139' observer.lat, observer.lon = '35', '139'
@@ -123,7 +120,7 @@ class Main:
# Youtube Chat から取得したコメントたち # Youtube Chat から取得したコメントたち
chat_items: list = [] chat_items: list = []
# 会話の履歴(3 件分保持) # 会話の履歴
histories: list = [] histories: list = []
while (True): while (True):
@@ -146,29 +143,30 @@ 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,
sunrise_start, sunrise_end, sunset_start, sunset_end, sunrise_start, sunrise_end, sunset_start, sunset_end,
sun_alt) sun_alt, moon_alt, moon_days_old)
# 左上に時刻表示 # 左上に時刻表示
for i in range (4): for i in range (4):
@@ -298,7 +296,7 @@ class Main:
bg_grass, kita, jojoko, bg_grass, kita, jojoko,
sunrise_start, sunrise_end, sunrise_start, sunrise_end,
sunset_start, sunset_end, sunset_start, sunset_end,
sun_alt) sun_alt, moon_alt, moon_days_old)
chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ', chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ',
'id': '', 'id': '',
@@ -324,24 +322,29 @@ class Main:
@classmethod @classmethod
def draw_bg ( def draw_bg (
cls, cls,
screen: pygame.Surface, screen: pygame.Surface,
bg_day: pygame.Surface, bg_day: pygame.Surface,
bg_evening: pygame.Surface, bg_evening: pygame.Surface,
bg_night: pygame.Surface, bg_night: pygame.Surface,
bg_grass: pygame.Surface, bg_grass: pygame.Surface,
kita: pygame.Surface, kita: pygame.Surface,
jojoko: pygame.Surface, jojoko_original: pygame.Surface,
sunrise_start: datetime, sunrise_start: datetime,
sunrise_end: datetime, sunrise_end: datetime,
sunset_start: datetime, sunset_start: datetime,
sunset_end: datetime, sunset_end: datetime,
sun_alt: float) \ sun_alt: float,
moon_alt: float,
moon_days_old: 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 = cls.get_jojoko (jojoko_original,
moon_days_old)
dt: datetime = datetime.now () dt: datetime = datetime.now ()
if sunrise_centre <= dt < sunset_centre: if sunrise_centre <= dt < sunset_centre:
@@ -358,8 +361,20 @@ class Main:
else: else:
bg_evening.set_alpha (0) 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)) screen.blit (bg_evening, (0, 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: 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)
@@ -367,6 +382,32 @@ class Main:
screen.blit (bg_grass, (0, 0)) 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__': if __name__ == '__main__':
Main.main (sys.argv, len (sys.argv)) Main.main (sys.argv, len (sys.argv))
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 728 KiB

変更後

幅:  |  高さ:  |  サイズ: 641 KiB

+21 -13
ファイルの表示
@@ -2,23 +2,31 @@ import pygame
from pygame.locals import * from pygame.locals import *
import sys import sys
from common_const import *
class Othello: class Othello:
# 盤の色 SCREEN_SIZE: tuple = (640, 480)
BOARD_COLOUR: tuple = (0, 128, 0) BOARD_COLOUR: tuple = (0, 128, 0)
def __init__ ( @classmethod
self, def main (cls) -> None:
screen: pygame.Surface) \ pygame.init ()
-> None: screen: pygame.Surface = pygame.display.set_mode (cls.SCREEN_SIZE)
self.screen = screen
# オセロ中? while True:
self.othello_mode = False screen.fill ((0, 0, 0))
def redraw (self) -> None: # pygame.draw.rect (screen, BOARD_COLOUR, )
if self.othello_mode:
pass pygame.display.update ()
pygame.time.wait (33)
for event in pygame.event.get ():
if event.type == QUIT:
pygame.quit ()
sys.exit ()
if __name__ == '__main__':
Othello.main ()