Browse Source

bouncing scrape gif bubble

magfest_edits
Frank DeMarco 2 years ago
parent
commit
fa70497b03
  1. 67
      NS.py
  2. 2
      config
  3. BIN
      resource/gif/Boarding_0.gif
  4. BIN
      resource/gif/Boarding_1.gif
  5. BIN
      resource/gif/Boarding_2.gif
  6. BIN
      resource/gif/Boarding_3.gif
  7. BIN
      resource/gif/Boarding_4.gif
  8. 2
      resource/scores
  9. BIN
      www/Boarding_0.gif
  10. 1
      www/Boarding_0.gif
  11. BIN
      www/Boarding_1.gif
  12. 1
      www/Boarding_1.gif
  13. BIN
      www/Boarding_2.gif
  14. 1
      www/Boarding_2.gif
  15. BIN
      www/Boarding_3.gif
  16. 1
      www/Boarding_3.gif
  17. BIN
      www/Multiplay_Closing-Flan.gif
  18. 1
      www/Multiplay_Closing-Flan.gif

67
NS.py

@ -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()

2
config

@ -26,7 +26,7 @@ sfx-volume = .8
[input]
buffer = 0
arduino-port = /dev/ttyACM0
serial = no
serial = yes
[time]
timer-max-time = 10000

BIN
resource/gif/Boarding_0.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 MiB

BIN
resource/gif/Boarding_1.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 MiB

BIN
resource/gif/Boarding_2.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

BIN
resource/gif/Boarding_3.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

BIN
resource/gif/Boarding_4.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 MiB

2
resource/scores

@ -17,3 +17,5 @@
312561
173960
237842
171298
164711

BIN
www/Boarding_0.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 MiB

After

Width:  |  Height:  |  Size: 30 B

1
www/Boarding_0.gif

@ -0,0 +1 @@
../resource/gif/Boarding_0.gif

Before

Width:  |  Height:  |  Size: 5.3 MiB

After

Width:  |  Height:  |  Size: 30 B

BIN
www/Boarding_1.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 MiB

After

Width:  |  Height:  |  Size: 30 B

1
www/Boarding_1.gif

@ -0,0 +1 @@
../resource/gif/Boarding_1.gif

Before

Width:  |  Height:  |  Size: 8.1 MiB

After

Width:  |  Height:  |  Size: 30 B

BIN
www/Boarding_2.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 MiB

After

Width:  |  Height:  |  Size: 30 B

1
www/Boarding_2.gif

@ -0,0 +1 @@
../resource/gif/Boarding_2.gif

Before

Width:  |  Height:  |  Size: 5.0 MiB

After

Width:  |  Height:  |  Size: 30 B

BIN
www/Boarding_3.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 MiB

After

Width:  |  Height:  |  Size: 30 B

1
www/Boarding_3.gif

@ -0,0 +1 @@
../resource/gif/Boarding_3.gif

Before

Width:  |  Height:  |  Size: 6.4 MiB

After

Width:  |  Height:  |  Size: 30 B

BIN
www/Multiplay_Closing-Flan.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 MiB

After

Width:  |  Height:  |  Size: 30 B

1
www/Multiplay_Closing-Flan.gif

@ -0,0 +1 @@
../resource/gif/Boarding_4.gif

Before

Width:  |  Height:  |  Size: 5.2 MiB

After

Width:  |  Height:  |  Size: 30 B

Loading…
Cancel
Save