sfx
This commit is contained in:
parent
b703633b68
commit
c84db0d152
106
NS.py
106
NS.py
|
@ -3,8 +3,11 @@
|
||||||
from random import randint, choice
|
from random import randint, choice
|
||||||
from math import pi
|
from math import pi
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
from glob import iglob
|
||||||
|
from os.path import basename
|
||||||
|
|
||||||
from pygame import Surface, Color
|
from pygame import Surface, Color
|
||||||
|
from pygame.event import clear
|
||||||
from pygame.mixer import Sound
|
from pygame.mixer import Sound
|
||||||
from pygame.image import load
|
from pygame.image import load
|
||||||
from pygame.transform import rotate, flip
|
from pygame.transform import rotate, flip
|
||||||
|
@ -47,7 +50,7 @@ class SoundEffect(GameChild, Sound):
|
||||||
class NS(Game, Animation):
|
class NS(Game, Animation):
|
||||||
|
|
||||||
LNW, LNE, LSE, LSW = range(4)
|
LNW, LNE, LSE, LSW = range(4)
|
||||||
N, E, S, W, NE, NW = range(6)
|
N, NE, E, NW, S, W = range(6)
|
||||||
FRONT_WIDTH = 230
|
FRONT_WIDTH = 230
|
||||||
BACK_WIDTH = 500
|
BACK_WIDTH = 500
|
||||||
LENGTH = 150
|
LENGTH = 150
|
||||||
|
@ -57,6 +60,7 @@ class NS(Game, Animation):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Game.__init__(self)
|
Game.__init__(self)
|
||||||
Animation.__init__(self, self)
|
Animation.__init__(self, self)
|
||||||
|
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)
|
||||||
|
@ -72,6 +76,12 @@ class NS(Game, Animation):
|
||||||
self.boss = Boss(self)
|
self.boss = Boss(self)
|
||||||
self.last_press = get_ticks()
|
self.last_press = get_ticks()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
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 reset(self, leave_wipe_running=False):
|
def reset(self, leave_wipe_running=False):
|
||||||
self.suppressing_input = False
|
self.suppressing_input = False
|
||||||
|
@ -146,6 +156,7 @@ class Title(GameChild):
|
||||||
self.text.add_frameset([1], name="half")
|
self.text.add_frameset([1], name="half")
|
||||||
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"]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.activate()
|
self.activate()
|
||||||
|
@ -189,9 +200,11 @@ class Title(GameChild):
|
||||||
self.first_pressed = True
|
self.first_pressed = True
|
||||||
self.first_pressed_elapsed = 0
|
self.first_pressed_elapsed = 0
|
||||||
self.text.set_frameset("half")
|
self.text.set_frameset("half")
|
||||||
|
self.button_sound.play()
|
||||||
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()
|
||||||
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:
|
||||||
|
@ -211,7 +224,7 @@ class Dialogue(Animation):
|
||||||
FONT_SIZE = 18
|
FONT_SIZE = 18
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
Animation.__init__(self, parent, interval=70)
|
Animation.__init__(self, parent)
|
||||||
ds = self.get_display_surface()
|
ds = self.get_display_surface()
|
||||||
dsr = ds.get_rect()
|
dsr = ds.get_rect()
|
||||||
frame = Surface((640, 72))
|
frame = Surface((640, 72))
|
||||||
|
@ -259,14 +272,16 @@ 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.play()
|
self.play()
|
||||||
|
|
||||||
def build_frame(self):
|
def build_frame(self):
|
||||||
self.text_index += 1
|
self.text_index += 2
|
||||||
if self.text_index == len(self.full_text):
|
if self.text_index >= len(self.full_text):
|
||||||
self.halt()
|
self.show_all()
|
||||||
|
|
||||||
def show_all(self):
|
def show_all(self):
|
||||||
|
self.speech_channel.stop()
|
||||||
self.text_index = len(self.full_text)
|
self.text_index = len(self.full_text)
|
||||||
self.halt()
|
self.halt()
|
||||||
|
|
||||||
|
@ -358,6 +373,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()
|
||||||
|
|
||||||
def take_board(self):
|
def take_board(self):
|
||||||
self.skateboard.hide()
|
self.skateboard.hide()
|
||||||
|
@ -405,6 +421,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"].play()
|
||||||
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()
|
||||||
|
@ -433,6 +450,7 @@ class SkipPrompt(Sprite):
|
||||||
for ii in xrange(3):
|
for ii in xrange(3):
|
||||||
self.load_from_path(self.get_resource("Skip_%i.png" % ii), True)
|
self.load_from_path(self.get_resource("Skip_%i.png" % ii), True)
|
||||||
self.add_frameset([ii])
|
self.add_frameset([ii])
|
||||||
|
self.button_sound = self.get_game().sfx["button"]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.press_index = 0
|
self.press_index = 0
|
||||||
|
@ -444,11 +462,14 @@ class SkipPrompt(Sprite):
|
||||||
if self.press_index == 0 and platform.get_edge_pressed() == NS.S:
|
if self.press_index == 0 and platform.get_edge_pressed() == NS.S:
|
||||||
self.press_index += 1
|
self.press_index += 1
|
||||||
self.set_frameset(2)
|
self.set_frameset(2)
|
||||||
|
self.button_sound.play()
|
||||||
elif self.press_index == 1 and platform.get_edge_pressed() == NS.NE:
|
elif self.press_index == 1 and platform.get_edge_pressed() == NS.NE:
|
||||||
self.press_index += 1
|
self.press_index += 1
|
||||||
self.set_frameset(3)
|
self.set_frameset(3)
|
||||||
|
self.button_sound.play()
|
||||||
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()
|
||||||
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:
|
||||||
|
@ -483,9 +504,13 @@ class AdvancePrompt(Sprite):
|
||||||
def press_first(self):
|
def press_first(self):
|
||||||
self.first_pressed = True
|
self.first_pressed = True
|
||||||
self.set_frameset("half")
|
self.set_frameset("half")
|
||||||
|
self.get_game().sfx["button"].play()
|
||||||
|
|
||||||
def check_second_press(self):
|
def check_second_press(self):
|
||||||
return 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:
|
||||||
|
self.get_game().sfx["confirm"].play()
|
||||||
|
return pressed
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.first_pressed:
|
if self.first_pressed:
|
||||||
|
@ -505,6 +530,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"]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.deactivate()
|
self.deactivate()
|
||||||
|
@ -519,10 +545,11 @@ class Wipe(Animation):
|
||||||
def start(self, callback):
|
def start(self, callback):
|
||||||
self.activate()
|
self.activate()
|
||||||
self.up = True
|
self.up = True
|
||||||
self.get_game().suppress_input()
|
# self.get_game().suppress_input()
|
||||||
self.blind_height = self.get_display_surface().get_height() / self.BLIND_COUNT
|
self.blind_height = self.get_display_surface().get_height() / self.BLIND_COUNT
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.play()
|
self.play()
|
||||||
|
self.sound.play()
|
||||||
|
|
||||||
def build_frame(self):
|
def build_frame(self):
|
||||||
if self.up:
|
if self.up:
|
||||||
|
@ -759,14 +786,15 @@ class Light(Animation):
|
||||||
return orientation in (NS.S, NS.NE, NS.W)
|
return orientation in (NS.S, NS.NE, NS.W)
|
||||||
|
|
||||||
|
|
||||||
class Chemtrails(GameChild):
|
class Chemtrails(Sprite):
|
||||||
|
|
||||||
TIME_LIMIT = 8000
|
|
||||||
TIME_ADDITION = 1000
|
TIME_ADDITION = 1000
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
GameChild.__init__(self, parent)
|
Sprite.__init__(self, parent)
|
||||||
self.image = load(self.get_resource("Chemtrails.png")).convert_alpha()
|
self.load_from_path(self.get_resource("littleSlimeGoop"), True)
|
||||||
|
for direction in (NS.N, NS.NE, NS.E, NS.NW, NS.S, NS.W):
|
||||||
|
self.add_frameset([direction], switch=(direction == NS.N))
|
||||||
self.life = Life(self)
|
self.life = Life(self)
|
||||||
self.timer = Timer(self)
|
self.timer = Timer(self)
|
||||||
|
|
||||||
|
@ -788,6 +816,7 @@ class Chemtrails(GameChild):
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.active:
|
if self.active:
|
||||||
self.orient()
|
self.orient()
|
||||||
|
Sprite.update(self)
|
||||||
if not self.get_game().introduction.active:
|
if not self.get_game().introduction.active:
|
||||||
boss = self.get_game().boss
|
boss = self.get_game().boss
|
||||||
if boss.queue:
|
if boss.queue:
|
||||||
|
@ -818,50 +847,42 @@ class Chemtrails(GameChild):
|
||||||
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"].play()
|
||||||
|
else:
|
||||||
|
self.get_game().sfx["land"].play()
|
||||||
self.get_game().platform.reset_lights()
|
self.get_game().platform.reset_lights()
|
||||||
|
|
||||||
def orient(self):
|
def orient(self):
|
||||||
ds = self.get_display_surface()
|
ds = self.get_display_surface()
|
||||||
edge = self.get_game().platform.get_edge_pressed()
|
edge = self.get_game().platform.get_edge_pressed()
|
||||||
dy = -Light.INTRODUCTION_OFFSET if self.get_game().introduction.active else 0
|
dy = -Light.INTRODUCTION_OFFSET if self.get_game().introduction.active else 0
|
||||||
|
if edge is not None:
|
||||||
|
self.set_frameset(edge + 1)
|
||||||
|
self.unhide()
|
||||||
|
else:
|
||||||
|
self.hide()
|
||||||
if edge == NS.N:
|
if edge == NS.N:
|
||||||
rect = self.image.get_rect()
|
self.location.center = ds.get_width() / 2, NS.FRONT + 15 + dy
|
||||||
rect.center = ds.get_width() / 2, NS.FRONT - 30 + dy
|
|
||||||
ds.blit(self.image, rect.topleft)
|
|
||||||
self.orientation = NS.N
|
self.orientation = NS.N
|
||||||
elif edge == NS.E:
|
elif edge == NS.E:
|
||||||
image = rotate(self.image, 270)
|
self.location.center = ds.get_width() / 2 + NS.FRONT_WIDTH / 2 - 115, \
|
||||||
rect = image.get_rect()
|
NS.FRONT + NS.LENGTH * NS.STEP - 75 + dy
|
||||||
rect.center = ds.get_width() / 2 + NS.FRONT_WIDTH / 2, \
|
|
||||||
NS.FRONT + NS.LENGTH * NS.STEP + 10 + dy
|
|
||||||
ds.blit(image, rect.topleft)
|
|
||||||
self.orientation = NS.E
|
self.orientation = NS.E
|
||||||
elif edge == NS.S:
|
elif edge == NS.S:
|
||||||
rect = self.image.get_rect()
|
self.location.center = ds.get_width() / 2, \
|
||||||
rect.center = ds.get_width() / 2, \
|
NS.FRONT + NS.LENGTH - NS.LENGTH * NS.STEP - 110 + dy
|
||||||
NS.FRONT + NS.LENGTH - NS.LENGTH * NS.STEP - 20 + dy
|
|
||||||
ds.blit(self.image, rect.topleft)
|
|
||||||
self.orientation = NS.S
|
self.orientation = NS.S
|
||||||
elif edge == NS.W:
|
elif edge == NS.W:
|
||||||
image = rotate(self.image, 270)
|
self.location.center = ds.get_width() / 2 - NS.FRONT_WIDTH / 2 + 100, \
|
||||||
rect = image.get_rect()
|
NS.FRONT + NS.LENGTH * NS.STEP - 85 + dy
|
||||||
rect.center = ds.get_width() / 2 - NS.FRONT_WIDTH / 2 + 70, \
|
|
||||||
NS.FRONT + NS.LENGTH * NS.STEP + 10 + dy
|
|
||||||
ds.blit(image, rect.topleft)
|
|
||||||
self.orientation = NS.W
|
self.orientation = NS.W
|
||||||
elif edge == NS.NW:
|
elif edge == NS.NW:
|
||||||
image = rotate(self.image, 315)
|
self.location.center = ds.get_width() / 2 + 5, \
|
||||||
rect = image.get_rect()
|
NS.FRONT + NS.LENGTH * NS.STEP - 75 + dy
|
||||||
rect.center = ds.get_width() / 2 + 45, \
|
|
||||||
NS.FRONT + NS.LENGTH * NS.STEP - 40 + dy
|
|
||||||
ds.blit(image, rect.topleft)
|
|
||||||
self.orientation = NS.NW
|
self.orientation = NS.NW
|
||||||
elif edge == NS.NE:
|
elif edge == NS.NE:
|
||||||
image = rotate(self.image, 45)
|
self.location.center = ds.get_width() / 2 + 10, \
|
||||||
rect = image.get_rect()
|
NS.FRONT + NS.LENGTH * NS.STEP - 80 + dy
|
||||||
rect.center = ds.get_width() / 2 - 30, \
|
|
||||||
NS.FRONT + NS.LENGTH * NS.STEP - 50 + dy
|
|
||||||
ds.blit(image, rect.topleft)
|
|
||||||
self.orientation = NS.NE
|
self.orientation = NS.NE
|
||||||
else:
|
else:
|
||||||
self.orientation = None
|
self.orientation = None
|
||||||
|
@ -871,8 +892,8 @@ class Timer(GameChild):
|
||||||
|
|
||||||
TEXT = u"\u25F7"
|
TEXT = u"\u25F7"
|
||||||
BAR_POSITION = 448, 11
|
BAR_POSITION = 448, 11
|
||||||
MAX_TIME = 9000
|
MAX_TIME = 10000
|
||||||
START_TIME = 6000
|
START_TIME = 7000
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
GameChild.__init__(self, parent)
|
GameChild.__init__(self, parent)
|
||||||
|
@ -928,6 +949,7 @@ class Life(GameChild):
|
||||||
self.count = 3
|
self.count = 3
|
||||||
|
|
||||||
def decrease(self):
|
def decrease(self):
|
||||||
|
self.get_game().sfx["hurt"].play()
|
||||||
if self.count > 0:
|
if self.count > 0:
|
||||||
self.count -= 1
|
self.count -= 1
|
||||||
if self.count <= 0:
|
if self.count <= 0:
|
||||||
|
@ -1006,7 +1028,7 @@ class Boss(Animation):
|
||||||
dialogue.activate()
|
dialogue.activate()
|
||||||
if self.level_index == 0:
|
if self.level_index == 0:
|
||||||
dialogue.show_text("You'll never be able to block my sword, you lizard slime!" +
|
dialogue.show_text("You'll never be able to block my sword, you lizard slime!" +
|
||||||
" See if you\ncan keep up with these moves!")
|
" See\nif you can keep up with these moves!")
|
||||||
elif self.level_index == 1:
|
elif self.level_index == 1:
|
||||||
dialogue.show_text("We're just warming up, slime breath! Prepare to get spun" +
|
dialogue.show_text("We're just warming up, slime breath! Prepare to get spun" +
|
||||||
" by\nthese combos!")
|
" by\nthese combos!")
|
||||||
|
@ -1344,6 +1366,7 @@ class Sword(Sprite):
|
||||||
else:
|
else:
|
||||||
self.set_frameset("rdiagonal")
|
self.set_frameset("rdiagonal")
|
||||||
self.location.center = dsr.centerx, dsr.centery - 100
|
self.location.center = dsr.centerx, dsr.centery - 100
|
||||||
|
self.get_game().sfx["brandish"].play()
|
||||||
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=600, play_once=True)
|
self.play(self.brandish, delay=600, play_once=True)
|
||||||
|
@ -1382,6 +1405,7 @@ class Health(GameChild):
|
||||||
self.parent.damage()
|
self.parent.damage()
|
||||||
if self.amount <= 0:
|
if self.amount <= 0:
|
||||||
self.amount = 0
|
self.amount = 0
|
||||||
|
self.get_game().sfx["defeat"].play()
|
||||||
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)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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