このコミットが含まれているのは:
@@ -51,17 +51,25 @@ def main (
|
|||||||
x = CWindow.WIDTH * 3 / 4,
|
x = CWindow.WIDTH * 3 / 4,
|
||||||
y = CWindow.HEIGHT - 120,
|
y = CWindow.HEIGHT - 120,
|
||||||
balloon = balloon)
|
balloon = balloon)
|
||||||
|
snack_time = SnackTime (game)
|
||||||
CurrentTime (game, SYSTEM_FONT)
|
CurrentTime (game, SYSTEM_FONT)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
|
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
waiting_balloon = (False, '', '')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get ():
|
for event in pygame.event.get ():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
pygame.quit ()
|
pygame.quit ()
|
||||||
sys.exit ()
|
sys.exit ()
|
||||||
if not balloon.enabled:
|
if (not balloon.enabled) and (not snack_time.enabled):
|
||||||
|
if waiting_balloon[0]:
|
||||||
|
deerjika.talk (waiting_balloon[1], waiting_balloon[2])
|
||||||
|
waiting_balloon = (False, '', '')
|
||||||
try:
|
try:
|
||||||
DB.begin_transaction ()
|
DB.begin_transaction ()
|
||||||
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value)
|
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value)
|
||||||
@@ -70,11 +78,18 @@ def main (
|
|||||||
if answer_flags:
|
if answer_flags:
|
||||||
answer_flag = random.choice (answer_flags)
|
answer_flag = random.choice (answer_flags)
|
||||||
answer = Answer.find (answer_flag.answer_id)
|
answer = Answer.find (answer_flag.answer_id)
|
||||||
if answer.query_rel.query_type == QueryType.YOUTUBE_COMMENT.value:
|
match QueryType (answer.query_rel.query_type):
|
||||||
|
case QueryType.YOUTUBE_COMMENT:
|
||||||
query = Query.find (answer.query_id)
|
query = Query.find (answer.query_id)
|
||||||
deerjika.talk (query.content, answer.content)
|
deerjika.talk (query.content, answer.content)
|
||||||
answer_flag.answered = True
|
answer_flag.answered = True
|
||||||
answer_flag.save ()
|
answer_flag.save ()
|
||||||
|
case QueryType.SNACK_TIME:
|
||||||
|
snack_time.play ()
|
||||||
|
query = Query.find (answer.query_id)
|
||||||
|
waiting_balloon = (True, query.content, answer.content)
|
||||||
|
answer_flag.answered = True
|
||||||
|
answer_flag.save ()
|
||||||
DB.commit ()
|
DB.commit ()
|
||||||
add_query (broadcast)
|
add_query (broadcast)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@@ -171,7 +186,7 @@ class Game:
|
|||||||
self.fps = FPS
|
self.fps = FPS
|
||||||
self.frame = 0
|
self.frame = 0
|
||||||
self.objects = []
|
self.objects = []
|
||||||
self.bgm = Sound ('assets/bgm.mp3')
|
self.bgm = Sound ('./assets/bgm.mp3')
|
||||||
self.bgm.set_volume (.15)
|
self.bgm.set_volume (.15)
|
||||||
self.bgm.play (loops = -1)
|
self.bgm.play (loops = -1)
|
||||||
self._create_sky ()
|
self._create_sky ()
|
||||||
@@ -292,10 +307,10 @@ class BgBase (GameObject):
|
|||||||
layer: float,
|
layer: float,
|
||||||
):
|
):
|
||||||
super ().__init__ (game, layer = layer)
|
super ().__init__ (game, layer = layer)
|
||||||
self.bg = self._load_image ('assets/bg.jpg')
|
self.bg = self._load_image ('./assets/bg.jpg')
|
||||||
self.bg_evening = self._load_image ('assets/bg-evening.jpg')
|
self.bg_evening = self._load_image ('./assets/bg-evening.jpg')
|
||||||
self.bg_grass = self._load_image ('assets/bg-grass.png')
|
self.bg_grass = self._load_image ('./assets/bg-grass.png')
|
||||||
self.bg_night = self._load_image ('assets/bg-night.jpg')
|
self.bg_night = self._load_image ('./assets/bg-night.jpg')
|
||||||
self.sun = sun
|
self.sun = sun
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -356,7 +371,7 @@ class BgGrass (GameObject):
|
|||||||
):
|
):
|
||||||
super ().__init__ (game)
|
super ().__init__ (game)
|
||||||
self.game = game
|
self.game = game
|
||||||
self.surface = pygame.image.load ('assets/bg-grass.png')
|
self.surface = pygame.image.load ('./assets/bg-grass.png')
|
||||||
self.surface = pygame.transform.scale (self.surface, (CWindow.WIDTH, CWindow.HEIGHT))
|
self.surface = pygame.transform.scale (self.surface, (CWindow.WIDTH, CWindow.HEIGHT))
|
||||||
|
|
||||||
def redraw (
|
def redraw (
|
||||||
@@ -420,14 +435,14 @@ class Deerjika (Creature):
|
|||||||
case Direction.LEFT:
|
case Direction.LEFT:
|
||||||
self.width = 1280
|
self.width = 1280
|
||||||
self.height = 720
|
self.height = 720
|
||||||
surface = pygame.image.load ('assets/deerjika_relax_left.png')
|
surface = pygame.image.load ('./assets/deerjika_relax_left.png')
|
||||||
self.surfaces = []
|
self.surfaces = []
|
||||||
for x in range (0, surface.get_width (), self.width):
|
for x in range (0, surface.get_width (), self.width):
|
||||||
self.surfaces.append (
|
self.surfaces.append (
|
||||||
surface.subsurface (x, 0, self.width, self.height))
|
surface.subsurface (x, 0, self.width, self.height))
|
||||||
case Direction.RIGHT:
|
case Direction.RIGHT:
|
||||||
...
|
...
|
||||||
self.sound = Sound ('assets/noon.wav')
|
self.sound = Sound ('./assets/noon.wav')
|
||||||
|
|
||||||
def redraw (
|
def redraw (
|
||||||
self,
|
self,
|
||||||
@@ -505,10 +520,10 @@ class CurrentTime (GameObject):
|
|||||||
def redraw (
|
def redraw (
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
for i in range (4):
|
for i in range (2):
|
||||||
self.game.screen.blit (
|
cl = (i * 255, i * 255, i * 255)
|
||||||
self.font.render (f"{ self.game.now } { self.game.fps } fps", True, (0, 0, 0)),
|
self.game.screen.blit (self.font.render (str (self.game.now), True, cl), (-i, -i))
|
||||||
(i % 2, i // 2 * 2))
|
self.game.screen.blit (self.font.render ('%2.3f fps' % self.game.fps, True, cl), (-i, 24 - i))
|
||||||
super ().redraw ()
|
super ().redraw ()
|
||||||
|
|
||||||
|
|
||||||
@@ -543,7 +558,7 @@ class Balloon (GameObject):
|
|||||||
super ().__init__ (game, enabled = False)
|
super ().__init__ (game, enabled = False)
|
||||||
self.x_flip = x_flip
|
self.x_flip = x_flip
|
||||||
self.y_flip = y_flip
|
self.y_flip = y_flip
|
||||||
self.surface = pygame.transform.scale (pygame.image.load ('assets/balloon.png'),
|
self.surface = pygame.transform.scale (pygame.image.load ('./assets/balloon.png'),
|
||||||
(CWindow.WIDTH, CWindow.HEIGHT / 2))
|
(CWindow.WIDTH, CWindow.HEIGHT / 2))
|
||||||
self.surface = pygame.transform.flip (self.surface, self.x_flip, self.y_flip)
|
self.surface = pygame.transform.flip (self.surface, self.x_flip, self.y_flip)
|
||||||
|
|
||||||
@@ -610,7 +625,7 @@ class KitaSun (GameObject):
|
|||||||
game: Game,
|
game: Game,
|
||||||
):
|
):
|
||||||
super ().__init__ (game)
|
super ().__init__ (game)
|
||||||
self.surface = pygame.transform.scale (pygame.image.load ('assets/sun.png'), (200, 200))
|
self.surface = pygame.transform.scale (pygame.image.load ('./assets/sun.png'), (200, 200))
|
||||||
self.sun = Sun ()
|
self.sun = Sun ()
|
||||||
|
|
||||||
def redraw (
|
def redraw (
|
||||||
@@ -674,7 +689,7 @@ class Jojoko (GameObject):
|
|||||||
game: Game,
|
game: Game,
|
||||||
):
|
):
|
||||||
super ().__init__ (game)
|
super ().__init__ (game)
|
||||||
self.base = pygame.transform.scale (pygame.image.load ('assets/moon.png'), (200, 200))
|
self.base = pygame.transform.scale (pygame.image.load ('./assets/moon.png'), (200, 200))
|
||||||
self.moon = Moon ()
|
self.moon = Moon ()
|
||||||
self.surface = self._get_surface ()
|
self.surface = self._get_surface ()
|
||||||
|
|
||||||
@@ -899,14 +914,15 @@ class Video (GameObject):
|
|||||||
def redraw (
|
def redraw (
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.game.screen.blit (self.surfaces[self.frame], (self.x, self.y))
|
surface = pygame.transform.scale (self.surfaces[self.frame], (self.width, self.height))
|
||||||
|
self.game.screen.blit (surface, (self.x, self.y))
|
||||||
super ().redraw ()
|
super ().redraw ()
|
||||||
|
|
||||||
def update (
|
def update (
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
if self.frame >= len (self.surfaces) - 1:
|
if self.frame >= len (self.surfaces) - 1:
|
||||||
self.pause ()
|
self.stop ()
|
||||||
if self.pausing:
|
if self.pausing:
|
||||||
self.frame -= 1
|
self.frame -= 1
|
||||||
super ().update ()
|
super ().update ()
|
||||||
@@ -916,6 +932,16 @@ class NicoVideo (Video):
|
|||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class SnackTime (Video):
|
||||||
|
def __init__ (
|
||||||
|
self,
|
||||||
|
game: Game,
|
||||||
|
):
|
||||||
|
super ().__init__ (game, './assets/snack_time.mp4')
|
||||||
|
(self.width, self.height) = (CWindow.HEIGHT * 16 // 9, CWindow.HEIGHT)
|
||||||
|
(self.x, self.y) = ((CWindow.WIDTH - self.width) / 2, 0)
|
||||||
|
|
||||||
|
|
||||||
def fetch_bytes_from_url (
|
def fetch_bytes_from_url (
|
||||||
url: str,
|
url: str,
|
||||||
) -> bytes | None:
|
) -> bytes | None:
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする