all repos — Legends-RPG @ 05d9e3d3d1f5fd253dc04a612313eac3b634def0

A fantasy mini-RPG built with Python and Pygame.

Began implementing boss battle.
Justin Armstrong justinmeister@gmail.com
Fri, 09 May 2014 18:43:29 -0700
commit

05d9e3d3d1f5fd253dc04a612313eac3b634def0

parent

adcb4e5b63401d7a453cda039c1d39f6448070a4

M data/components/person.pydata/components/person.py

@@ -40,6 +40,7 @@ self.observers = []

self.level = 1 self.health = 0 self.death_image = pg.transform.scale2x(self.image) + self.battle = None def create_spritesheet_dict(self, sheet_key): """Implemented by inheriting classes"""

@@ -113,8 +114,6 @@ self.image_list = self.animation_dict[self.direction]

state_function = self.state_dict[self.state] state_function() self.location = self.get_tile_location() - - def set_blockers(self): """Sets blockers to prevent collision with other sprites"""

@@ -472,6 +471,7 @@ self.healing = False

self.damage_alpha = 0 self.healing_alpha = 0 self.fade_in = True + def create_vector_dict(self): """Return a dictionary of x and y velocities set to
M data/components/textbox.pydata/components/textbox.py

@@ -142,6 +142,15 @@ elif self.textbox.name == 'infobox':

self.textbox = ItemBox(dialogue, index) elif self.talking_sprite.item: self.check_for_item() + elif self.talking_sprite.battle: + self.game_data['battle type'] = self.talking_sprite.battle + self.dialogue_reset() + self.talking_sprite = None + self.level.state = 'normal' + self.level.switch_to_battle = True + self.textbox = None + self.last_textbox_timer = current_time + self.reset_sprite_direction() else: self.dialogue_reset() self.talking_sprite = None
M data/constants.pydata/constants.py

@@ -16,6 +16,11 @@ HOUSE = 'house'

OVERWORLD = 'overworld' BROTHER_HOUSE = 'brother_house' BATTLE = 'battle' +DUNGEON = 'dungeon' +DUNGEON2 = 'dungeon2' +DUNGEON3 = 'dungeon3' +DUNGEON4 = 'dungeon4' +DUNGEON5 = 'dungeon5' ##Colors
M data/main.pydata/main.py

@@ -43,7 +43,7 @@ DUNGEON: levels.LevelState(DUNGEON, True),

DUNGEON2: levels.LevelState(DUNGEON2, True), DUNGEON3: levels.LevelState(DUNGEON3, True), DUNGEON4: levels.LevelState(DUNGEON4, True), - DUNGEON5: levels.LevelState(DUNGEON5) + DUNGEON5: levels.LevelState(DUNGEON5, True) } run_it.setup_states(state_dict, c.MAIN_MENU)
M data/states/battle.pydata/states/battle.py

@@ -42,6 +42,7 @@ def startup(self, current_time, game_data):

"""Initialize state attributes""" self.current_time = current_time self.timer = current_time + self.allow_input = False self.game_data = game_data self.inventory = game_data['player inventory'] self.state = c.SELECT_ACTION

@@ -77,8 +78,7 @@ background_group = pg.sprite.Group(background)

return background_group - @staticmethod - def make_enemies(): + def make_enemies(self): """Make the enemies for the battle. Return sprite group""" pos_list = []

@@ -90,9 +90,14 @@ pos_list.append([x, y])

enemy_group = pg.sprite.Group() - for enemy in range(random.randint(1, 6)): - enemy_group.add(person.Person('devil', 0, 0, - 'down', 'battle resting')) + if self.game_data['battle type']: + enemy = person.Person('evilwizard', 0, 0, + 'down', 'battle resting') + enemy_group.add(enemy) + else: + for enemy in range(random.randint(1, 6)): + enemy_group.add(person.Person('devil', 0, 0, + 'down', 'battle resting')) for i, enemy in enumerate(enemy_group): enemy.rect.topleft = pos_list[i]

@@ -254,8 +259,11 @@ def end_battle(self):

""" End battle and flip back to previous state. """ + if self.game_data['battle type'] == 'evilwizard': + self.game_data['crown quest'] = True self.game_data['last state'] = self.name self.game_data['battle counter'] = random.randint(50, 255) + self.game_data['battle type'] = None self.done = True def attack_enemy(self, enemy_damage):
M data/states/levels.pydata/states/levels.py

@@ -145,6 +145,11 @@ id = properties['id']

else: id = None + if 'battle' in properties: + battle = properties['battle'] + else: + battle = None + x = properties['x'] * 2 y = ((properties['y']) * 2) - 32

@@ -165,6 +170,7 @@ 'soldier': person.Person('soldier',

x, y, direction, 'resting', index), 'king': person.Person('king', x, y, direction), + 'evilwizard': person.Person('evilwizard', x, y, direction), 'treasurechest': person.Chest(x, y, id)} sprite = sprite_dict[properties['type']]

@@ -176,9 +182,13 @@ else:

sprite.item = item else: sprite.item = item + sprite.battle = battle self.assign_dialogue(sprite, properties) self.check_for_opened_chest(sprite) - sprites.add(sprite) + if sprite.name == 'evilwizard' and self.game_data['crown quest']: + pass + else: + sprites.add(sprite) return sprites
M data/tools.pydata/tools.py

@@ -212,7 +212,9 @@ 'treasure5': True,

'brother quest complete': False, 'has brother elixir': False, 'elixir received': False, - 'old man gift': '' + 'old man gift': '', + 'battle type': '', + 'crown quest': False } return data_dict
M resources/tmx/dungeon5.tmxresources/tmx/dungeon5.tmx

@@ -28,8 +28,9 @@ eJxjYBgFo2BkgGImBoYSJuqaeQqNPxlo/hQq2zEKRsEoGPoAADzUAuE=

</data> </layer> <objectgroup name="Object Layer 1" width="25" height="19"> - <object name="sprite" type="oldmanbrother" gid="65" x="192" y="160"> + <object name="sprite" type="evilwizard" gid="65" x="192" y="160"> <properties> + <property name="battle" value="evilwizard"/> <property name="dialogue length" value="1"/> <property name="dialogue0" value="You will never have this crown!"/> </properties>