Added music to a bunch of the levels.
Justin Armstrong justinmeister@gmail.com
Sun, 25 May 2014 12:43:40 -0700
11 files changed,
33 insertions(+),
0 deletions(-)
M
README.md
→
README.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.py
→
data/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.py
→
data/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.py
→
data/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.py
→
data/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