preload gif frames, move music into resource folder
This commit is contained in:
parent
81beea7f5e
commit
e88c4b8937
|
@ -1,3 +1,3 @@
|
||||||
[submodule "lib/pgfw"]
|
[submodule "lib/pgfw"]
|
||||||
path = lib/pgfw
|
path = lib/pgfw
|
||||||
url = /home/pi/projects/scrapeboard_copy/lib/pgfw
|
url = frank@shampoo.ooo:/var/www/git/pgfw
|
||||||
|
|
45
NS.py
45
NS.py
|
@ -814,11 +814,11 @@ class Video(Sprite):
|
||||||
Sprite.__init__(self, parent, 100)
|
Sprite.__init__(self, parent, 100)
|
||||||
self.next_video_chance = next_video_chance
|
self.next_video_chance = next_video_chance
|
||||||
pattern = join(self.get_resource("gif"), "Boarding_*.gif")
|
pattern = join(self.get_resource("gif"), "Boarding_*.gif")
|
||||||
self.gifs = []
|
gifs = []
|
||||||
for path in iglob(pattern):
|
for path in iglob(pattern):
|
||||||
self.gifs.append(Image.open(path))
|
gifs.append(Image.open(path))
|
||||||
print(self.gifs[-1].info)
|
print(gifs[-1].info)
|
||||||
self.gif = self.gifs[1]
|
self.gif_index = 0
|
||||||
self.mask = Surface([diameter] * 2, SRCALPHA)
|
self.mask = Surface([diameter] * 2, SRCALPHA)
|
||||||
rect = self.mask.get_rect()
|
rect = self.mask.get_rect()
|
||||||
alpha = int(self.get_configuration("display", "attract-gif-alpha") * 255)
|
alpha = int(self.get_configuration("display", "attract-gif-alpha") * 255)
|
||||||
|
@ -827,25 +827,36 @@ class Video(Sprite):
|
||||||
self.add_frame(self.mask)
|
self.add_frame(self.mask)
|
||||||
if not self.get_configuration("system", "minimize-load-time"):
|
if not self.get_configuration("system", "minimize-load-time"):
|
||||||
self.play()
|
self.play()
|
||||||
|
# preload GIF frames scaled instead of loading each frame like before
|
||||||
|
self.gif_frames_scaled = []
|
||||||
|
for gif in gifs:
|
||||||
|
self.gif_frames_scaled.append([])
|
||||||
|
for ii in range(0, gif.n_frames):
|
||||||
|
gif.seek(ii)
|
||||||
|
frame_scaled = smoothscale(
|
||||||
|
fromstring(gif.convert("RGBA").tobytes(), gif.size, "RGBA"),
|
||||||
|
(self.mask.get_width(), int(gif.width * gif.height / self.mask.get_width())))
|
||||||
|
copy = self.mask.copy()
|
||||||
|
rect = frame_scaled.get_rect()
|
||||||
|
rect.bottom = copy.get_rect().bottom
|
||||||
|
copy.blit(frame_scaled, rect, None, BLEND_RGBA_MIN)
|
||||||
|
self.gif_frames_scaled[-1].append(copy)
|
||||||
|
self.load_selection()
|
||||||
|
|
||||||
|
def load_selection(self):
|
||||||
|
self.clear_frames()
|
||||||
|
for frame in self.gif_frames_scaled[self.gif_index]:
|
||||||
|
self.add_frame(frame)
|
||||||
|
|
||||||
def shift_frame(self):
|
def shift_frame(self):
|
||||||
Sprite.shift_frame(self)
|
Sprite.shift_frame(self)
|
||||||
if random() < self.next_video_chance:
|
if random() < self.next_video_chance:
|
||||||
while True:
|
while True:
|
||||||
selection = choice(self.gifs)
|
selection = choice(range(0, len(self.gif_frames_scaled)))
|
||||||
if selection != self.gif:
|
if selection != self.gif_index:
|
||||||
self.gif = selection
|
self.gif_index = selection
|
||||||
|
self.load_selection()
|
||||||
break
|
break
|
||||||
self.gif.seek((self.gif.tell() + 1) % self.gif.n_frames)
|
|
||||||
frame = smoothscale(
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
class Logo(Sprite):
|
class Logo(Sprite):
|
||||||
|
|
10
config
10
config
|
@ -80,11 +80,11 @@ ending-timeout = 22000
|
||||||
lizard-hurt-length = 2000
|
lizard-hurt-length = 2000
|
||||||
|
|
||||||
[bgm]
|
[bgm]
|
||||||
title = resource/bgm/title.ogg, .65
|
title = bgm/title.ogg, 1.0
|
||||||
level_0 = /home/frank/storage/audio/bgm/bat-tree-habitat-key/level-0.wav, .65
|
level_0 = bgm/level_0.ogg, .65
|
||||||
level_1 = /home/frank/storage/audio/bgm/esp-hadouken/Cube-Levers.ogg, .65
|
level_1 = bgm/level_1.ogg, .65
|
||||||
level_2 = /home/frank/storage/audio/bgm/esp-hadouken/Bog.ogg, .65
|
level_2 = bgm/level_2.ogg, .65
|
||||||
end = /home/frank/storage/audio/bgm/phone-call-from-magnet.wav, .65
|
end = bgm/end.ogg, .65
|
||||||
|
|
||||||
[pads]
|
[pads]
|
||||||
nw_color = #00FF88
|
nw_color = #00FF88
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue