all repos — Legends-RPG @ 5db3d7e67c6601aad8156f1f7ef88fceb69ad109

A fantasy mini-RPG built with Python and Pygame.

Added music to a bunch of the levels.
Justin Armstrong justinmeister@gmail.com
Sun, 25 May 2014 12:43:40 -0700
commit

5db3d7e67c6601aad8156f1f7ef88fceb69ad109

parent

bc9dbbaff0f24475c11c5f6a992e77532b9db02c

M README.mdREADME.md

@@ -6,3 +6,7 @@

![screenshot](https://raw.github.com/justinmeister/The-Stolen-Crown-RPG/master/screenshot.png) ![screenshot #2](https://raw.github.com/justinmeister/The-Stolen-Crown-RPG/master/screenshot-2.png) + +King's Theme by Telaron: opengameart.org/content/the-kings-crowning +Town Theme by Mekathratos: opengameart.org/content/danza-del-bosque +Overworld Theme by bart: opengameart.org/content/adventure-begins
M data/states/battle.pydata/states/battle.py

@@ -11,6 +11,7 @@ class Battle(tools._State):

def __init__(self): super(Battle, self).__init__() self.name = 'battle' + self.music = setup.MUSIC['high_action'] def startup(self, current_time, game_data): """Initialize state attributes"""
M data/states/levels.pydata/states/levels.py

@@ -9,6 +9,7 @@

import copy import pygame as pg from .. import tools, collision +from .. import constants as c from .. components import person, textbox, portal from . import player_menu from .. import tilerender

@@ -22,6 +23,26 @@ super(LevelState, self).__init__()

self.name = name self.tmx_map = setup.TMX[name] self.allow_battles = battles + self.music = self.set_music() + + def set_music(self): + """ + Set music based on name. + """ + music_dict = {c.TOWN: 'town_theme', + c.OVERWORLD: 'overworld', + c.CASTLE: 'kings_theme', + c.DUNGEON:'dungeon_theme', + c.DUNGEON2: 'dungeon_theme', + c.DUNGEON3: 'dungeon_theme', + c.DUNGEON4: 'dungeon_theme', + c.DUNGEON5: 'dungeon_theme'} + + if self.name in music_dict: + music = music_dict[self.name] + return setup.MUSIC[music] + else: + return None def startup(self, current_time, game_data): """
M data/states/shop.pydata/states/shop.py

@@ -18,6 +18,7 @@ def __init__(self):

super(Shop, self).__init__() self.key = None self.sell_items = None + self.music = setup.MUSIC['shop_theme'] def startup(self, current_time, game_data): """Startup state"""
M data/tools.pydata/tools.py

@@ -41,6 +41,11 @@ previous, self.state_name = self.state_name, self.state.next

persist = self.state.cleanup() self.state = self.state_dict[self.state_name] self.state.previous = previous + if self.state.music: + pg.mixer.music.load(self.state.music) + pg.mixer.music.play() + else: + pg.mixer.music.stop() self.state.startup(self.current_time, persist) def event_loop(self):

@@ -88,6 +93,7 @@ self.quit = False

self.next = None self.previous = None self.game_data = {} + self.music = None def get_event(self, event): pass