Browse Source

背景時間帯によって変動

othello
みてるぞ 4 months ago
parent
commit
7517fa251b
3 changed files with 33 additions and 4 deletions
  1. BIN
      bg-evening.jpg
  2. BIN
      bg-night.jpg
  3. +33
    -4
      main.py

BIN
bg-evening.jpg View File

Before After
Width: 800  |  Height: 600  |  Size: 57 KiB

BIN
bg-night.jpg View File

Before After
Width: 827  |  Height: 528  |  Size: 38 KiB

+ 33
- 4
main.py View File

@@ -1,3 +1,5 @@
# vim: nosmartindent autoindent

import json
import random
import subprocess
@@ -21,7 +23,11 @@ from youtube import *

class Main:
@classmethod
def main (cls, argv: list, argc: int) -> None:
def main (
cls,
argv: list,
argc: int) \
-> None:
mode = Mode.NIZIKA
match (argc > 1) and argv[1]:
case '-g':
@@ -47,6 +53,16 @@ class Main:
if goatoh_mode:
balloon = pygame.transform.flip (balloon, False, True)

# 背景(夕方)
bg_evening: pygame.Surface = pygame.transform.scale (
pygame.image.load ('bg-evening.jpg'),
(CWindow.WIDTH, CWindow.HEIGHT))

# 背景(夜)
bg_night: pygame.Surface = pygame.transform.scale (
pygame.image.load ('bg-night.jpg'),
(CWindow.WIDTH, CWindow.HEIGHT))

# 音声再生器の初期化
pygame.mixer.init (frequency = 44100)

@@ -78,7 +94,7 @@ class Main:
histories: list = []

while (True):
screen.fill ((0, 255, 0))
cls.draw_bg (screen, bg_evening, bg_night)

# 左上に時刻表示
for i in range (4):
@@ -201,7 +217,7 @@ class Main:
if not double_mode or random.random () < .5:
break

screen.fill ((0, 255, 0))
cls.draw_bg (screen, bg_evening, bg_night)

chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ',
'id': '',
@@ -224,8 +240,21 @@ class Main:
pygame.quit ()
sys.exit ()

@classmethod
def draw_bg (
cls,
screen: pygame.Surface,
bg_evening: pygame.Surface,
bg_night: pygame.Surface) \
-> None:
if 17 <= (h := datetime.now ().hour) < 18:
screen.blit (bg_evening, (0, 0))
elif (h < 6) or (18 <= h):
screen.blit (bg_night, (0, 0))
else:
screen.fill ((0, 255, 0))


if __name__ == '__main__':
# Main.main ((len (sys.argv) > 1) and (sys.argv[1] == '-g'))
Main.main (sys.argv, len (sys.argv))


Loading…
Cancel
Save