|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from random import randint, choice
|
|
|
|
|
from random import randint, choice, random
|
|
|
|
|
from math import pi
|
|
|
|
|
from copy import copy
|
|
|
|
|
from glob import iglob
|
|
|
|
@ -9,16 +9,17 @@ from threading import Thread
|
|
|
|
|
from serial import Serial, SerialException
|
|
|
|
|
from serial.tools import list_ports
|
|
|
|
|
from time import sleep
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
|
|
from pygame import Surface, Color, mixer
|
|
|
|
|
from pygame.event import clear
|
|
|
|
|
from pygame.mixer import Sound
|
|
|
|
|
from pygame.image import load, fromstring
|
|
|
|
|
from pygame.transform import rotate, flip
|
|
|
|
|
from pygame.transform import rotate, flip, scale
|
|
|
|
|
from pygame.time import get_ticks
|
|
|
|
|
from pygame.font import Font
|
|
|
|
|
from pygame.draw import aalines, lines
|
|
|
|
|
from pygame.gfxdraw import aapolygon, arc, polygon, aaellipse, ellipse, filled_ellipse
|
|
|
|
|
from pygame.gfxdraw import aapolygon, arc, polygon, aaellipse, ellipse, filled_ellipse, filled_circle
|
|
|
|
|
from pygame.locals import *
|
|
|
|
|
|
|
|
|
|
from lib.pgfw.pgfw.Game import Game
|
|
|
|
@ -212,12 +213,12 @@ class NS(Game, Animation):
|
|
|
|
|
print("auto arduino reset triggered")
|
|
|
|
|
self.reset_arduino()
|
|
|
|
|
self.no_reset_elapsed = 0
|
|
|
|
|
self.title.update()
|
|
|
|
|
self.introduction.update()
|
|
|
|
|
self.ending.update()
|
|
|
|
|
self.boss.update()
|
|
|
|
|
self.platform.update()
|
|
|
|
|
self.chemtrails.update()
|
|
|
|
|
self.title.update()
|
|
|
|
|
self.boss.update_dialogue()
|
|
|
|
|
self.wipe.update()
|
|
|
|
|
self.idle_elapsed += self.time_filter.get_last_frame_duration()
|
|
|
|
@ -336,6 +337,42 @@ class Tony(Sprite):
|
|
|
|
|
self.add_frame(frame)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Video(Sprite):
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
|
Sprite.__init__(self, parent, 100)
|
|
|
|
|
pattern = join(self.get_resource("gif"), "Boarding_*.gif")
|
|
|
|
|
self.gifs = []
|
|
|
|
|
for path in iglob(pattern):
|
|
|
|
|
self.gifs.append(Image.open(path))
|
|
|
|
|
print(self.gifs[-1].info)
|
|
|
|
|
self.gif = self.gifs[1]
|
|
|
|
|
self.mask = Surface((320, 320), SRCALPHA)
|
|
|
|
|
rect = self.mask.get_rect()
|
|
|
|
|
filled_circle(self.mask, rect.centerx, rect.centery, rect.centerx, (255, 255, 255))
|
|
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
|
if random() < .01:
|
|
|
|
|
while True:
|
|
|
|
|
selection = choice(self.gifs)
|
|
|
|
|
if selection != self.gif:
|
|
|
|
|
self.gif = selection
|
|
|
|
|
break
|
|
|
|
|
if random() < .005:
|
|
|
|
|
self.toggle_hidden()
|
|
|
|
|
self.gif.seek((self.gif.tell() + 1) % self.gif.n_frames)
|
|
|
|
|
frame = scale(
|
|
|
|
|
fromstring(self.gif.convert("RGBA").tobytes(), self.gif.size, "RGBA"),
|
|
|
|
|
(self.mask.get_width(), int(self.gif.width * self.gif.height / self.mask.get_width())))
|
|
|
|
|
copy = self.mask.copy()
|
|
|
|
|
rect = frame.get_rect()
|
|
|
|
|
rect.bottom = copy.get_rect().bottom
|
|
|
|
|
copy.blit(frame, rect, None, BLEND_RGBA_MIN)
|
|
|
|
|
self.clear_frames()
|
|
|
|
|
self.add_frame(copy)
|
|
|
|
|
Sprite.update(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Title(GameChild):
|
|
|
|
|
|
|
|
|
|
UNLOCK_MOVES = NS.N, NS.NW, NS.E, NS.S
|
|
|
|
@ -347,7 +384,8 @@ class Title(GameChild):
|
|
|
|
|
ds = self.get_display_surface()
|
|
|
|
|
dsr = ds.get_rect()
|
|
|
|
|
self.plank.location.center = dsr.center
|
|
|
|
|
self.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4))
|
|
|
|
|
# self.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4))
|
|
|
|
|
self.angle = 7 * pi / 4
|
|
|
|
|
self.background = Sprite(self)
|
|
|
|
|
self.background.load_from_path(self.get_resource("Title_tile.png"), True)
|
|
|
|
|
for y in range(0, dsr.h + self.background.location.h, self.background.location.h):
|
|
|
|
@ -362,6 +400,7 @@ class Title(GameChild):
|
|
|
|
|
for x in range(0, dsr.w, thickness):
|
|
|
|
|
frame.fill(palette[(offset + x) % len(palette)], (x, 0, thickness, dsr.h))
|
|
|
|
|
self.effect.add_frame(frame)
|
|
|
|
|
self.video = Video(self)
|
|
|
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
|
self.first_pressed = False
|
|
|
|
@ -452,6 +491,24 @@ class Title(GameChild):
|
|
|
|
|
if self.first_pressed_elapsed > 1000 * 60 * 1:
|
|
|
|
|
self.reset()
|
|
|
|
|
platform.update()
|
|
|
|
|
self.get_game().chemtrails.update()
|
|
|
|
|
# bounce the gif around the screen
|
|
|
|
|
if self.video.location.right > dsr.right or self.video.location.left < dsr.left:
|
|
|
|
|
self.angle = reflect_angle(self.angle, 0)
|
|
|
|
|
if self.video.location.right > dsr.right:
|
|
|
|
|
self.video.move(dsr.right - self.video.location.right)
|
|
|
|
|
else:
|
|
|
|
|
self.video.move(dsr.left - self.video.location.left)
|
|
|
|
|
if self.video.location.bottom > dsr.bottom or self.video.location.top < dsr.top:
|
|
|
|
|
self.angle = reflect_angle(self.angle, pi)
|
|
|
|
|
if self.video.location.bottom > dsr.bottom:
|
|
|
|
|
self.video.move(dy=dsr.bottom - self.video.location.bottom)
|
|
|
|
|
else:
|
|
|
|
|
self.video.move(dy=dsr.top - self.video.location.top)
|
|
|
|
|
dx, dy = get_delta(self.angle, 5, False)
|
|
|
|
|
self.video.move(dx, dy)
|
|
|
|
|
if not platform.get_pressed():
|
|
|
|
|
self.video.update()
|
|
|
|
|
self.draw_scores()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|