diff --git a/.gitmodules b/.gitmodules index f687d49..73d8794 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lib/pgfw"] path = lib/pgfw - url = /home/pi/projects/scrapeboard_copy/lib/pgfw + url = frank@shampoo.ooo:/var/www/git/pgfw diff --git a/NS.py b/NS.py index 3be6d21..8a2847a 100644 --- a/NS.py +++ b/NS.py @@ -814,11 +814,11 @@ class Video(Sprite): Sprite.__init__(self, parent, 100) self.next_video_chance = next_video_chance pattern = join(self.get_resource("gif"), "Boarding_*.gif") - self.gifs = [] + gifs = [] for path in iglob(pattern): - self.gifs.append(Image.open(path)) - print(self.gifs[-1].info) - self.gif = self.gifs[1] + gifs.append(Image.open(path)) + print(gifs[-1].info) + self.gif_index = 0 self.mask = Surface([diameter] * 2, SRCALPHA) rect = self.mask.get_rect() alpha = int(self.get_configuration("display", "attract-gif-alpha") * 255) @@ -827,25 +827,36 @@ class Video(Sprite): self.add_frame(self.mask) if not self.get_configuration("system", "minimize-load-time"): 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): Sprite.shift_frame(self) if random() < self.next_video_chance: while True: - selection = choice(self.gifs) - if selection != self.gif: - self.gif = selection + selection = choice(range(0, len(self.gif_frames_scaled))) + if selection != self.gif_index: + self.gif_index = selection + self.load_selection() 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): diff --git a/config b/config index 3c5e704..0706258 100644 --- a/config +++ b/config @@ -80,11 +80,11 @@ ending-timeout = 22000 lizard-hurt-length = 2000 [bgm] -title = resource/bgm/title.ogg, .65 -level_0 = /home/frank/storage/audio/bgm/bat-tree-habitat-key/level-0.wav, .65 -level_1 = /home/frank/storage/audio/bgm/esp-hadouken/Cube-Levers.ogg, .65 -level_2 = /home/frank/storage/audio/bgm/esp-hadouken/Bog.ogg, .65 -end = /home/frank/storage/audio/bgm/phone-call-from-magnet.wav, .65 +title = bgm/title.ogg, 1.0 +level_0 = bgm/level_0.ogg, .65 +level_1 = bgm/level_1.ogg, .65 +level_2 = bgm/level_2.ogg, .65 +end = bgm/end.ogg, .65 [pads] nw_color = #00FF88 diff --git a/resource/bgm/end.ogg b/resource/bgm/end.ogg index 6ce1d39..3a51017 100644 Binary files a/resource/bgm/end.ogg and b/resource/bgm/end.ogg differ diff --git a/resource/bgm/level_0.ogg b/resource/bgm/level_0.ogg index f2f874d..20a366e 100644 Binary files a/resource/bgm/level_0.ogg and b/resource/bgm/level_0.ogg differ diff --git a/resource/bgm/level_1.ogg b/resource/bgm/level_1.ogg index 7166c46..4b68de8 100644 Binary files a/resource/bgm/level_1.ogg and b/resource/bgm/level_1.ogg differ diff --git a/resource/bgm/level_2.ogg b/resource/bgm/level_2.ogg index 7c70fbe..bee349b 100644 Binary files a/resource/bgm/level_2.ogg and b/resource/bgm/level_2.ogg differ diff --git a/resource/bgm/title.ogg b/resource/bgm/title.ogg index 38d1d8d..81ceedd 100644 Binary files a/resource/bgm/title.ogg and b/resource/bgm/title.ogg differ