Browse Source

attract mode work in progress

magfest_edits
Frank DeMarco 2 years ago
parent
commit
772263e918
  1. 98
      NS.py
  2. 38
      record_test.py
  3. BIN
      resource/Big_Tony.png
  4. BIN
      resource/Title_plank.png

98
NS.py

@ -158,6 +158,7 @@ class NS(Game, Animation):
self.platform.reset()
self.dialogue.reset()
self.no_reset_elapsed = 0
self.title.activate()
def set_most_recent_time(self, score):
self.most_recent_time = score
@ -214,8 +215,7 @@ class NS(Game, Animation):
self.introduction.update()
self.ending.update()
self.boss.update()
if not self.introduction.active:
self.platform.update()
self.platform.update()
self.chemtrails.update()
self.boss.update_dialogue()
self.wipe.update()
@ -316,6 +316,8 @@ class Meter(GameChild):
class Title(GameChild):
UNLOCK_MOVES = NS.N, NS.NW, NS.E, NS.S
def __init__(self, parent):
GameChild.__init__(self, parent)
self.plank = Sprite(self)
@ -323,39 +325,28 @@ class Title(GameChild):
ds = self.get_display_surface()
dsr = ds.get_rect()
self.plank.location.center = dsr.center
self.slime_bag = Sprite(self)
self.slime_bag.load_from_path(self.get_resource("Title_slime_bag.png"), True)
self.slime_bag.location.bottomleft = dsr.bottomleft
image = load(self.get_resource("Title_border.png")).convert()
image.set_colorkey((0, 0, 0))
self.border = RainbowSprite(self, image, 30)
self.border.location.center = dsr.centerx, dsr.bottom - 100
self.text = Sprite(self)
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.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4))
self.button_sound = self.get_audio().sfx["button"]
self.buttons = Button(self, NS.N, 10, 4), Button(self, NS.NW, 10, 4)
self.buttons[0].location.center = 277, 381
self.buttons[1].location.center = 453, 381
self.tony = RainbowSprite(self, load(self.get_resource("Big_Tony.png")).convert_alpha(), 30, 500)
def reset(self):
self.activate()
self.first_pressed = False
self.first_pressed_elapsed = 0
for button in self.buttons:
button.unhide()
self.unlock_index = 0
def activate(self):
self.active = True
platform = self.get_game().platform
platform.activate()
platform.set_glowing(platform.get_buttons_from_edges([self.UNLOCK_MOVES[self.unlock_index]]))
self.get_game().chemtrails.activate()
def deactivate(self):
self.active = False
def activate_introduction(self):
def start_game(self):
self.deactivate()
self.get_game().introduction.activate()
self.get_game().set_most_recent_time(None)
self.get_game().boss.start_level(0)
def draw_scores(self):
step = 75
@ -372,7 +363,7 @@ class Title(GameChild):
text = entry
message = render_box(font, text, True, Color(255, 255, 255),
Color(128, 128, 128), Color(0, 0, 0), padding=2)
message.set_alpha(200)
message.set_alpha(230)
rect = message.get_rect()
rect.top = y
if ii < 5:
@ -392,10 +383,14 @@ class Title(GameChild):
return "%i:%02i.%i" % (minutes, seconds, fraction / 100)
def update(self):
'''
Move title, check button presses, and draw screen
'''
if self.active:
ds = self.get_display_surface()
ds.fill((255, 255, 255))
ds.fill((142, 207, 111))
dsr = ds.get_rect()
# bounce the title plank around the screen
if self.plank.location.right > dsr.right or self.plank.location.left < dsr.left:
self.angle = reflect_angle(self.angle, 0)
if self.plank.location.right > dsr.right:
@ -410,29 +405,28 @@ class Title(GameChild):
self.plank.move(dy=dsr.top - self.plank.location.top)
dx, dy = get_delta(self.angle, 2, False)
self.plank.move(dx, dy)
self.plank.update()
self.slime_bag.update()
wipe = self.get_game().wipe
if not self.first_pressed and self.get_game().platform.get_edge_pressed() == NS.N:
# self.plank.update()
self.tony.update()
# advance unlock pattern
platform = self.get_game().platform
if not self.get_game().wipe.is_playing() and platform.get_edge_pressed() == self.UNLOCK_MOVES[self.unlock_index]:
self.first_pressed = True
self.first_pressed_elapsed = 0
self.buttons[0].hide()
self.button_sound.play()
elif not wipe.is_playing() and self.first_pressed and \
self.get_game().platform.get_edge_pressed() == NS.NW:
wipe.start(self.activate_introduction)
self.get_audio().play_sfx("confirm")
elif self.first_pressed:
if self.unlock_index == len(self.UNLOCK_MOVES) - 1:
platform.set_glowing([])
self.get_game().wipe.start(self.start_game)
self.get_audio().play_sfx("confirm")
else:
platform.set_glowing(platform.get_buttons_from_edges([self.UNLOCK_MOVES[self.unlock_index]]))
self.get_audio().play_sfx("land_0")
self.unlock_index += 1
# reset unlock pattern if idle
if self.first_pressed:
self.first_pressed_elapsed += self.get_game().time_filter.get_last_frame_duration()
# if self.first_pressed_elapsed > 4000:
# self.first_pressed = False
# self.first_pressed_elapsed = 0
# self.buttons[0].unhide()
self.border.update()
self.text.update()
if self.first_pressed_elapsed > 1000 * 60 * 1:
self.reset()
platform.update()
self.draw_scores()
for button in self.buttons:
button.update()
class Dialogue(Animation):
@ -477,7 +471,7 @@ class Dialogue(Animation):
def stop_speech(self):
if self.speech_channel is not None:
self.speech_channel.stop()
self.speech_channel = None
self.speech_channel = None
def deactivate(self):
self.stop_speech()
@ -528,9 +522,9 @@ class Dialogue(Animation):
for ii, line in enumerate(lines):
surface = font.render(line, True, self.TEXT_COLOR)
frame.blit(surface, (0, 30 * ii))
message.add_frame(frame)
message.location.topleft = self.text_box.location.left + 9, self.text_box.location.top + 8
message.update()
message.add_frame(frame)
message.location.topleft = self.text_box.location.left + 9, self.text_box.location.top + 8
message.update()
class Introduction(Animation):
@ -1029,7 +1023,7 @@ class Platform(GameChild):
class Light(Animation):
MAX_GLOW_INDEX = 25
INTRODUCTION_OFFSET = 80
TITLE_OFFSET = 0
def __init__(self, parent, color, position):
Animation.__init__(self, parent)
@ -1077,7 +1071,7 @@ class Light(Animation):
def update(self):
Animation.update(self)
if not self.get_game().introduction.active:
if not self.get_game().title.active:
boss = self.get_game().boss
chemtrails = self.get_game().chemtrails
if boss.queue and boss.brandish_complete and not self.is_playing(self.glow) \
@ -1091,10 +1085,10 @@ class Light(Animation):
aa_filled_polygon(ds, self.get_points(), self.color)
def get_points(self):
if self.get_game().introduction.active:
if self.get_game().title.active:
points = []
for point in self.points:
points.append((point[0], point[1] - self.INTRODUCTION_OFFSET))
points.append((point[0], point[1] - self.TITLE_OFFSET))
return points
else:
return self.points
@ -1168,7 +1162,7 @@ class Chemtrails(Sprite):
if self.active:
self.orient()
Sprite.update(self)
if not self.get_game().introduction.active:
if not self.get_game().title.active:
boss = self.get_game().boss
if boss.queue:
self.timer.tick()
@ -1209,7 +1203,7 @@ class Chemtrails(Sprite):
def orient(self):
ds = self.get_display_surface()
edge = self.get_game().platform.get_edge_pressed()
dy = -Light.INTRODUCTION_OFFSET if self.get_game().introduction.active else 0
dy = -Light.TITLE_OFFSET if self.get_game().title.active else 0
if edge is not None:
self.set_frameset(edge + 1)
self.unhide()

38
record_test.py

@ -0,0 +1,38 @@
import pyaudio
import wave
CHUNK = 1024
FORMAT = pyaudio.paInt32
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
print("* recording")
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

BIN
resource/Big_Tony.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 134 KiB

BIN
resource/Title_plank.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Loading…
Cancel
Save