all repos — Legends-RPG @ 94f8ada01c1112b1b4b9d5e4c42845b68de043dd

A fantasy mini-RPG built with Python and Pygame.

Finished Credit scene.
Justin Armstrong justinmeister@gmail.com
Wed, 18 Jun 2014 09:49:29 -0700
commit

94f8ada01c1112b1b4b9d5e4c42845b68de043dd

parent

c0a1a80585351c8001637d8bf163dd13b033aaa7

3 files changed, 50 insertions(+), 10 deletions(-)

jump to
M data/states/credits.pydata/states/credits.py

@@ -9,13 +9,13 @@ """

The text for each credit for the game. """ def __init__(self, level): + self.alpha = 0 self.font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 22) self.credit_sprites = self.make_credits() self.index = 0 self.current_credit = self.credit_sprites[self.index] self.state_dict = self.make_state_dict() self.state = c.TRANSITION_IN - self.alpha = 0 self.timer = 0.0 self.level = level

@@ -25,9 +25,30 @@ Make a list of lists for all the credit surfaces.

""" credits = [['THE STOLEN CROWN', 'A Fantasy RPG'], ['PROGRAMMING AND GAME DESIGN', 'Justin Armstrong'], - ['ART', 'John Smith'], - ['MUSIC', 'John Smith'], - ['SPECIAL THANKS', '/r/pygame']] + ['ART', 'JPhilipp', + 'Reemax', + 'Lanea Zimmerman', + 'Redshrike', + 'StumpyStrust', + 'Benjamin Larsson', + 'russpuppy', + 'hc', + 'Iron Star Media'], + ['MUSIC', 'Telaron: The King\'s Theme', + 'Mekathratos: Forest Dance (Town Theme)', + 'bart: Adventure Begins (Overworld Theme)', + '8th Mode Music: High Action (Battle Theme)', + 'Arron Krogh: Coastal Town (Shop Theme)', + 'Arron Krogh: My Enemy (Dungeon Theme)', + 'Matthew Pablo: Enchanted Festival (Victory Theme)', + 'Matthew Pablo: Pleasant Creek (Brother Theme)'], + ['SOUND EFFECTS', 'Kenney', + 'Nic3_one', + 'Ekokubza123', + 'kuzyaburst'], + ['SPECIAL THANKS', '/r/pygame', + 'Leif Theden', + 'Stacey Hunniford']] credit_sprites = []

@@ -37,8 +58,10 @@ for i, subcredit in enumerate(credit):

text_sprite = pg.sprite.Sprite() text_sprite.text_image = self.font.render(subcredit, True, c.WHITE) text_sprite.rect = text_sprite.text_image.get_rect(centerx = 400, - y=250+(i*50)) - text_sprite.image = pg.Surface(text_sprite.rect.size) + y=100+(i*40)) + text_sprite.image = pg.Surface(text_sprite.rect.size).convert() + text_sprite.image.set_colorkey(c.BLACK) + text_sprite.image.set_alpha(self.alpha) subcredit_list.append(text_sprite) credit_sprites.append(subcredit_list)

@@ -86,7 +109,7 @@ self.current_credit = self.credit_sprites[self.index]

self.state = c.TRANSITION_IN def normal_update(self): - if (self.current_time - self.timer) > 2500: + if (self.current_time - self.timer) > 4500: self.state = c.TRANSITION_OUT def update(self, current_time):
M data/states/death.pydata/states/death.py

@@ -59,7 +59,9 @@ """

def __init__(self): super(DeathScene, self).__init__() self.next = c.TOWN - self.music = None + self.music = setup.MUSIC['shop_theme'] + self.volume = 0.5 + self.music_title = 'shop_theme' def startup(self, current_time, game_data): self.game_data = game_data
M data/states/levels.pydata/states/levels.py

@@ -312,7 +312,8 @@ state_dict = {'normal': self.running_normally,

'dialogue': self.handling_dialogue, 'menu': self.goto_menu, 'transition_in': self.transition_in, - 'transition_out': self.transition_out} + 'transition_out': self.transition_out, + 'slow transition out': self.slow_fade_out} return state_dict

@@ -398,7 +399,7 @@ Switch scene to credits if main quest is complete.

""" if self.game_data['delivered crown']: self.next = c.CREDITS - self.state = 'transition_out' + self.state = 'slow transition out' def set_new_start_pos(self): """

@@ -449,6 +450,20 @@ transition_image.set_alpha(self.transition_alpha)

self.draw_level(surface) surface.blit(transition_image, self.transition_rect) self.transition_alpha += c.TRANSITION_SPEED + if self.transition_alpha >= 255: + self.transition_alpha = 255 + self.done = True + + def slow_fade_out(self, surface, *args): + """ + Transition level to new scene. + """ + transition_image = pg.Surface(self.transition_rect.size) + transition_image.fill(c.TRANSITION_COLOR) + transition_image.set_alpha(self.transition_alpha) + self.draw_level(surface) + surface.blit(transition_image, self.transition_rect) + self.transition_alpha += 2 if self.transition_alpha >= 255: self.transition_alpha = 255 self.done = True