use audio obj auto sfx scanning feature
This commit is contained in:
parent
b09ff54d3b
commit
7b92f7ee12
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "lib/pgfw"]
|
||||||
|
path = lib/pgfw
|
||||||
|
url = makar:/var/www/git/pgfw
|
60
NS.py
60
NS.py
|
@ -25,7 +25,6 @@ from lib.pgfw.pgfw.Game import Game
|
||||||
from lib.pgfw.pgfw.GameChild import GameChild
|
from lib.pgfw.pgfw.GameChild import GameChild
|
||||||
from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite
|
from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite
|
||||||
from lib.pgfw.pgfw.Animation import Animation
|
from lib.pgfw.pgfw.Animation import Animation
|
||||||
from lib.pgfw.pgfw.Audio import SoundEffect
|
|
||||||
from lib.pgfw.pgfw.extension import (
|
from lib.pgfw.pgfw.extension import (
|
||||||
get_step, get_step_relative, get_delta, reflect_angle,
|
get_step, get_step_relative, get_delta, reflect_angle,
|
||||||
render_box, get_hsla_color, get_hue_shifted_surface,
|
render_box, get_hsla_color, get_hue_shifted_surface,
|
||||||
|
@ -61,7 +60,6 @@ class NS(Game, Animation):
|
||||||
})
|
})
|
||||||
Animation.__init__(self, self)
|
Animation.__init__(self, self)
|
||||||
mixer.init(44100, -16, self.CHANNEL_COUNT, 4096)
|
mixer.init(44100, -16, self.CHANNEL_COUNT, 4096)
|
||||||
self.load_sfx()
|
|
||||||
self.subscribe(self.respond, KEYDOWN)
|
self.subscribe(self.respond, KEYDOWN)
|
||||||
self.subscribe(self.respond, KEYUP)
|
self.subscribe(self.respond, KEYUP)
|
||||||
self.subscribe(self.respond)
|
self.subscribe(self.respond)
|
||||||
|
@ -97,11 +95,6 @@ class NS(Game, Animation):
|
||||||
self.most_recent_time = None
|
self.most_recent_time = None
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
def load_sfx(self):
|
|
||||||
sfx = self.sfx = {}
|
|
||||||
for path in iglob(self.get_resource("sfx/") + "*.wav"):
|
|
||||||
sfx[basename(path.split(".")[0])] = SoundEffect(self, path)
|
|
||||||
|
|
||||||
def serial_enabled(self):
|
def serial_enabled(self):
|
||||||
return self.get_configuration("input", "serial") and not self.check_command_line("-no-serial")
|
return self.get_configuration("input", "serial") and not self.check_command_line("-no-serial")
|
||||||
|
|
||||||
|
@ -255,7 +248,7 @@ class Button(Sprite):
|
||||||
colored = rects[3], rects[2]
|
colored = rects[3], rects[2]
|
||||||
elif edge == NS.W:
|
elif edge == NS.W:
|
||||||
colored = rects[0], rects[3]
|
colored = rects[0], rects[3]
|
||||||
for lightness in xrange(30, 90, 5):
|
for lightness in range(30, 90, 5):
|
||||||
frame = Surface((width, width), SRCALPHA)
|
frame = Surface((width, width), SRCALPHA)
|
||||||
for topleft in (0, 0), (step, 0), (step, step), (0, step):
|
for topleft in (0, 0), (step, 0), (step, step), (0, step):
|
||||||
rect = Rect(topleft, (rect_width, rect_width))
|
rect = Rect(topleft, (rect_width, rect_width))
|
||||||
|
@ -263,7 +256,7 @@ class Button(Sprite):
|
||||||
border_color.a = 179
|
border_color.a = 179
|
||||||
frame.fill(border_color, rect)
|
frame.fill(border_color, rect)
|
||||||
frame.fill((0, 0, 0, 0), rect.inflate(-border * 2, -border * 2))
|
frame.fill((0, 0, 0, 0), rect.inflate(-border * 2, -border * 2))
|
||||||
for ii in xrange(2):
|
for ii in range(2):
|
||||||
original_color = Color(*colors[ii])
|
original_color = Color(*colors[ii])
|
||||||
original_color.a = 255
|
original_color.a = 255
|
||||||
edited_color = Color(0, 0, 0)
|
edited_color = Color(0, 0, 0)
|
||||||
|
@ -338,7 +331,7 @@ class Title(GameChild):
|
||||||
self.text.load_from_path(self.get_resource("Title_text.png"), True, False, (255, 0, 0))
|
self.text.load_from_path(self.get_resource("Title_text.png"), True, False, (255, 0, 0))
|
||||||
self.text.location.center = dsr.centerx, dsr.bottom - 100
|
self.text.location.center = dsr.centerx, dsr.bottom - 100
|
||||||
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.button_sound = self.get_game().sfx["button"]
|
self.button_sound = self.get_audio().sfx["button"]
|
||||||
self.buttons = Button(self, NS.N, 10, 4), Button(self, NS.NW, 10, 4)
|
self.buttons = Button(self, NS.N, 10, 4), Button(self, NS.NW, 10, 4)
|
||||||
self.buttons[0].location.center = 277, 381
|
self.buttons[0].location.center = 277, 381
|
||||||
self.buttons[1].location.center = 453, 381
|
self.buttons[1].location.center = 453, 381
|
||||||
|
@ -364,7 +357,7 @@ class Title(GameChild):
|
||||||
def draw_scores(self):
|
def draw_scores(self):
|
||||||
step = 75
|
step = 75
|
||||||
ds = self.get_display_surface()
|
ds = self.get_display_surface()
|
||||||
lines = map(int, file(self.get_resource("scores")).readlines())
|
lines = map(int, open(self.get_resource("scores")).readlines())
|
||||||
entries = ["BEST"] + sorted(lines)[:9]
|
entries = ["BEST"] + sorted(lines)[:9]
|
||||||
for ii, entry in enumerate(entries):
|
for ii, entry in enumerate(entries):
|
||||||
if ii == 0 or ii == 5:
|
if ii == 0 or ii == 5:
|
||||||
|
@ -425,7 +418,7 @@ class Title(GameChild):
|
||||||
elif not wipe.is_playing() and self.first_pressed and \
|
elif not wipe.is_playing() and self.first_pressed and \
|
||||||
self.get_game().platform.get_edge_pressed() == NS.NW:
|
self.get_game().platform.get_edge_pressed() == NS.NW:
|
||||||
wipe.start(self.activate_introduction)
|
wipe.start(self.activate_introduction)
|
||||||
self.get_game().sfx["confirm"].play()
|
self.get_audio().play_sfx("confirm")
|
||||||
elif self.first_pressed:
|
elif self.first_pressed:
|
||||||
self.first_pressed_elapsed += self.get_game().time_filter.get_last_frame_duration()
|
self.first_pressed_elapsed += self.get_game().time_filter.get_last_frame_duration()
|
||||||
# if self.first_pressed_elapsed > 4000:
|
# if self.first_pressed_elapsed > 4000:
|
||||||
|
@ -504,7 +497,7 @@ class Dialogue(Animation):
|
||||||
def show_text(self, text):
|
def show_text(self, text):
|
||||||
self.full_text = text
|
self.full_text = text
|
||||||
self.text_index = 0
|
self.text_index = 0
|
||||||
self.speech_channel = self.get_game().sfx["talk"].play(-1)
|
self.speech_channel = self.get_audio().play_sfx("talk", -1)
|
||||||
self.play()
|
self.play()
|
||||||
|
|
||||||
def build_frame(self):
|
def build_frame(self):
|
||||||
|
@ -600,12 +593,13 @@ class Introduction(Animation):
|
||||||
# self.get_game().platform.unpress()
|
# self.get_game().platform.unpress()
|
||||||
|
|
||||||
def speak(self):
|
def speak(self):
|
||||||
for ii in xrange(self.words_index + 1):
|
for ii in range(self.words_index + 1):
|
||||||
self.words[ii].move(0, 12)
|
self.words[ii].move(0, 12)
|
||||||
if ii == self.words_index and self.words[ii].location.bottom > self.get_display_surface().get_rect().bottom - 40:
|
if ii == self.words_index and self.words[ii].location.bottom > self.get_display_surface().get_rect().bottom - 40:
|
||||||
if self.words_index < len(self.words) - 1:
|
if self.words_index < len(self.words) - 1:
|
||||||
self.words_index += 1
|
self.words_index += 1
|
||||||
self.words[self.words_index].unhide()
|
self.words[self.words_index].unhide()
|
||||||
|
self.get_audio().play_sfx("talk")
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.advance_prompt.cancel_first_press()
|
self.advance_prompt.cancel_first_press()
|
||||||
|
@ -639,7 +633,7 @@ class Introduction(Animation):
|
||||||
if self.skateboard.location.colliderect(self.slime_bag.location.inflate(-30, -30)):
|
if self.skateboard.location.colliderect(self.slime_bag.location.inflate(-30, -30)):
|
||||||
self.halt(self.move_board)
|
self.halt(self.move_board)
|
||||||
self.play(self.take_board, delay=2000, play_once=True)
|
self.play(self.take_board, delay=2000, play_once=True)
|
||||||
self.get_game().sfx["go"].play()
|
self.get_audio().play_sfx("go")
|
||||||
|
|
||||||
def take_board(self):
|
def take_board(self):
|
||||||
self.skateboard.hide()
|
self.skateboard.hide()
|
||||||
|
@ -687,7 +681,7 @@ class Introduction(Animation):
|
||||||
platform = self.get_game().platform
|
platform = self.get_game().platform
|
||||||
if platform.get_edge_pressed() == self.TUTORIAL_MOVES[self.tutorial_index]:
|
if platform.get_edge_pressed() == self.TUTORIAL_MOVES[self.tutorial_index]:
|
||||||
self.tutorial_index += 1
|
self.tutorial_index += 1
|
||||||
self.get_game().sfx["land_0"].play()
|
self.get_audio().play_sfx("land_0")
|
||||||
if self.tutorial_index == len(self.TUTORIAL_MOVES):
|
if self.tutorial_index == len(self.TUTORIAL_MOVES):
|
||||||
# self.text_index += 1
|
# self.text_index += 1
|
||||||
# self.advance_prompt.cancel_first_press()
|
# self.advance_prompt.cancel_first_press()
|
||||||
|
@ -737,7 +731,7 @@ class SkipPrompt(GameChild):
|
||||||
self.text.location.midleft = (
|
self.text.location.midleft = (
|
||||||
self.buttons[2].location.right + 5,
|
self.buttons[2].location.right + 5,
|
||||||
self.buttons[2].location.centery)
|
self.buttons[2].location.centery)
|
||||||
self.button_sound = self.get_game().sfx["button"]
|
self.button_sound = self.get_audio().sfx["button"]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.press_index = 0
|
self.press_index = 0
|
||||||
|
@ -761,7 +755,7 @@ class SkipPrompt(GameChild):
|
||||||
self.pluses[1].hide()
|
self.pluses[1].hide()
|
||||||
elif self.press_index == 2 and platform.get_edge_pressed() == NS.W:
|
elif self.press_index == 2 and platform.get_edge_pressed() == NS.W:
|
||||||
self.callback()
|
self.callback()
|
||||||
self.get_game().sfx["confirm"].play()
|
self.get_audio().play_sfx("confirm")
|
||||||
elif self.press_index > 0:
|
elif self.press_index > 0:
|
||||||
self.press_elapsed += self.get_game().time_filter.get_last_frame_duration()
|
self.press_elapsed += self.get_game().time_filter.get_last_frame_duration()
|
||||||
if self.press_elapsed > 4000:
|
if self.press_elapsed > 4000:
|
||||||
|
@ -812,12 +806,12 @@ class AdvancePrompt(GameChild):
|
||||||
self.first_pressed = True
|
self.first_pressed = True
|
||||||
self.buttons[0].hide()
|
self.buttons[0].hide()
|
||||||
self.plus.hide()
|
self.plus.hide()
|
||||||
self.get_game().sfx["button"].play()
|
self.get_audio().play_sfx("button")
|
||||||
|
|
||||||
def check_second_press(self):
|
def check_second_press(self):
|
||||||
pressed = self.first_pressed and self.get_game().platform.get_edge_pressed() == NS.NW
|
pressed = self.first_pressed and self.get_game().platform.get_edge_pressed() == NS.NW
|
||||||
if pressed:
|
if pressed:
|
||||||
self.get_game().sfx["confirm"].play()
|
self.get_audio().play_sfx("confirm")
|
||||||
return pressed
|
return pressed
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
@ -840,7 +834,7 @@ class Wipe(Animation):
|
||||||
Animation.__init__(self, parent)
|
Animation.__init__(self, parent)
|
||||||
self.image = load(self.get_resource("Ink.png")).convert()
|
self.image = load(self.get_resource("Ink.png")).convert()
|
||||||
self.image.set_colorkey(self.TRANSPARENT_COLOR)
|
self.image.set_colorkey(self.TRANSPARENT_COLOR)
|
||||||
self.sound = self.get_game().sfx["wipe"]
|
self.sound = self.get_audio().sfx["wipe"]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.deactivate()
|
self.deactivate()
|
||||||
|
@ -880,7 +874,7 @@ class Wipe(Animation):
|
||||||
ds = self.get_display_surface()
|
ds = self.get_display_surface()
|
||||||
dsr = ds.get_rect()
|
dsr = ds.get_rect()
|
||||||
frame = self.image.copy()
|
frame = self.image.copy()
|
||||||
for y in xrange(0, dsr.h, dsr.h / self.BLIND_COUNT):
|
for y in range(0, dsr.h, dsr.h // self.BLIND_COUNT):
|
||||||
if self.up:
|
if self.up:
|
||||||
frame.fill(self.TRANSPARENT_COLOR, (0, y, dsr.w, self.blind_height))
|
frame.fill(self.TRANSPARENT_COLOR, (0, y, dsr.w, self.blind_height))
|
||||||
else:
|
else:
|
||||||
|
@ -1103,7 +1097,7 @@ class Light(Animation):
|
||||||
return self.points
|
return self.points
|
||||||
|
|
||||||
def draw_glow(self):
|
def draw_glow(self):
|
||||||
for ii, y in enumerate(xrange(0, self.glow_index, 3)):
|
for ii, y in enumerate(range(0, self.glow_index, 3)):
|
||||||
shifted = []
|
shifted = []
|
||||||
for point in self.get_points():
|
for point in self.get_points():
|
||||||
shifted.append((point[0], point[1] - y))
|
shifted.append((point[0], point[1] - y))
|
||||||
|
@ -1204,9 +1198,9 @@ class Chemtrails(Sprite):
|
||||||
self.timer.reset()
|
self.timer.reset()
|
||||||
if not boss.is_playing(boss.show_end_dialogue):
|
if not boss.is_playing(boss.show_end_dialogue):
|
||||||
boss.combo()
|
boss.combo()
|
||||||
self.get_game().sfx["complete_pattern_3"].play()
|
self.get_audio().play_sfx("complete_pattern_3")
|
||||||
else:
|
else:
|
||||||
self.get_game().sfx["land_0"].play()
|
self.get_audio().play_sfx("land_0")
|
||||||
self.get_game().platform.reset_lights()
|
self.get_game().platform.reset_lights()
|
||||||
|
|
||||||
def orient(self):
|
def orient(self):
|
||||||
|
@ -1274,7 +1268,7 @@ class Life(Meter):
|
||||||
self.setup(background, rect, 70, (255, 0, 0), 3, "scrapeIcons/scrapeIcons_03.png")
|
self.setup(background, rect, 70, (255, 0, 0), 3, "scrapeIcons/scrapeIcons_03.png")
|
||||||
|
|
||||||
def decrease(self):
|
def decrease(self):
|
||||||
self.get_game().sfx["hurt"].play()
|
self.get_audio().play_sfx("hurt")
|
||||||
self.change(-1)
|
self.change(-1)
|
||||||
if self.amount <= 0:
|
if self.amount <= 0:
|
||||||
self.amount = 0
|
self.amount = 0
|
||||||
|
@ -1590,7 +1584,7 @@ class Boss(Animation):
|
||||||
|
|
||||||
def add_score(self):
|
def add_score(self):
|
||||||
self.get_game().set_most_recent_time(self.time_elapsed)
|
self.get_game().set_most_recent_time(self.time_elapsed)
|
||||||
file(self.get_resource("scores"), "a").write(str(self.time_elapsed) + "\n")
|
open(self.get_resource("scores"), "a").write(str(self.time_elapsed) + "\n")
|
||||||
|
|
||||||
def show_end_dialogue(self):
|
def show_end_dialogue(self):
|
||||||
dialogue = self.get_game().dialogue
|
dialogue = self.get_game().dialogue
|
||||||
|
@ -1690,7 +1684,7 @@ class Countdown(GameChild):
|
||||||
self.game_over.add_frame(font.render("GAME OVER", True, (0, 0, 0), (255, 255, 255)))
|
self.game_over.add_frame(font.render("GAME OVER", True, (0, 0, 0), (255, 255, 255)))
|
||||||
self.game_over.location.center = dsr.centerx, dsr.centery - 40
|
self.game_over.location.center = dsr.centerx, dsr.centery - 40
|
||||||
self.glyphs = []
|
self.glyphs = []
|
||||||
for ii in xrange(10):
|
for ii in range(10):
|
||||||
glyph = Sprite(self)
|
glyph = Sprite(self)
|
||||||
frame = Surface((140, 140))
|
frame = Surface((140, 140))
|
||||||
frame.fill((255, 255, 255))
|
frame.fill((255, 255, 255))
|
||||||
|
@ -1742,7 +1736,7 @@ class Sword(Animation):
|
||||||
swords.append([[], [], [], [], [], []])
|
swords.append([[], [], [], [], [], []])
|
||||||
for path in sorted(iglob(join(self.get_resource(root), "*.png"))):
|
for path in sorted(iglob(join(self.get_resource(root), "*.png"))):
|
||||||
base = load(self.get_resource(path)).convert_alpha()
|
base = load(self.get_resource(path)).convert_alpha()
|
||||||
for position in xrange(6):
|
for position in range(6):
|
||||||
if position == NS.N or position == NS.S:
|
if position == NS.N or position == NS.S:
|
||||||
rotated = rotate(base, 270)
|
rotated = rotate(base, 270)
|
||||||
elif position == NS.NW:
|
elif position == NS.NW:
|
||||||
|
@ -1764,7 +1758,7 @@ class Sword(Animation):
|
||||||
surface.fill(color_b, (0, rect.centery, rect.w, rect.h / 2), BLEND_RGBA_MIN)
|
surface.fill(color_b, (0, rect.centery, rect.w, rect.h / 2), BLEND_RGBA_MIN)
|
||||||
swords[-1][position].append(surface)
|
swords[-1][position].append(surface)
|
||||||
masks = self.masks = []
|
masks = self.masks = []
|
||||||
for alpha in xrange(16, 255, 16):
|
for alpha in range(16, 255, 16):
|
||||||
surface = Surface((300, 300), SRCALPHA)
|
surface = Surface((300, 300), SRCALPHA)
|
||||||
surface.fill((255, 255, 255, alpha))
|
surface.fill((255, 255, 255, alpha))
|
||||||
masks.append(surface)
|
masks.append(surface)
|
||||||
|
@ -1802,7 +1796,7 @@ class Sword(Animation):
|
||||||
else:
|
else:
|
||||||
sprite.location.center = dsr.centerx - offset, dsr.centery - 100
|
sprite.location.center = dsr.centerx - offset, dsr.centery - 100
|
||||||
self.sprites.append(sprite)
|
self.sprites.append(sprite)
|
||||||
self.get_game().sfx["brandish"].play()
|
self.get_audio().play_sfx("brandish")
|
||||||
self.play(self.lower, delay=400, play_once=True)
|
self.play(self.lower, delay=400, play_once=True)
|
||||||
if len(self.parent.unbrandished) > 0:
|
if len(self.parent.unbrandished) > 0:
|
||||||
self.play(self.brandish, delay=self.get_configuration("time", "sword-delay"),
|
self.play(self.brandish, delay=self.get_configuration("time", "sword-delay"),
|
||||||
|
@ -1861,8 +1855,8 @@ class Health(Meter):
|
||||||
self.parent.damage()
|
self.parent.damage()
|
||||||
if self.amount <= 0:
|
if self.amount <= 0:
|
||||||
self.amount = 0
|
self.amount = 0
|
||||||
self.get_game().sfx["complete_pattern_1"].play()
|
self.get_audio().play_sfx("complete_pattern_1")
|
||||||
self.get_game().sfx["defeat"].play()
|
self.get_audio().play_sfx("defeat")
|
||||||
self.get_game().boss.finish_battle(True)
|
self.get_game().boss.finish_battle(True)
|
||||||
else:
|
else:
|
||||||
self.parent.play(self.parent.cancel_flash, delay=1000, play_once=True)
|
self.parent.play(self.parent.cancel_flash, delay=1000, play_once=True)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5f2b26852e9fe8e910793cee46c14b8cbccaf962
|
Loading…
Reference in New Issue