all repos — Legends-RPG @ 7728ded4533e4190e419a6c010b6e07c67e1d583

A fantasy mini-RPG built with Python and Pygame.

Improved dungeon, fixed some bugs.
Justin Armstrong justinmeister@gmail.com
Mon, 05 May 2014 21:36:04 -0700
commit

7728ded4533e4190e419a6c010b6e07c67e1d583

parent

61fca12ff6593e7b348fd6831f7f0323d1a3ac7c

M data/collision.pydata/collision.py

@@ -95,10 +95,11 @@ def check_for_battle(self):

""" Switch scene to battle 1/5 times if battles are allowed. """ - random_number = random.randint(0, 15) + if self.level.allow_battles: + self.level.game_data['battle counter'] -= 5 - if random_number == 0: - self.level.switch_to_battle = True + if self.level.game_data['battle counter'] <= 0: + self.level.switch_to_battle = True
M data/states/battle.pydata/states/battle.py

@@ -171,7 +171,7 @@ if self.game_data['player stats']['magic points']['current'] >= 25:

self.state = c.CURE_SPELL self.notify(self.state) elif self.info_box.magic_text_list[self.arrow.index] == 'Fire Blast': - if self.game_data['player stats']['magic points']['current'] >= 75: + if self.game_data['player stats']['magic points']['current'] >= 25: self.state = c.FIRE_SPELL self.notify(self.state)

@@ -251,6 +251,7 @@ """

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

@@ -6,7 +6,7 @@ This class inherits from the generic state class

found in the tools.py module. """ -import copy +import copy, random import pygame as pg from .. import tools, collision from .. components import person, textbox, portal

@@ -38,9 +38,7 @@

self.viewport = self.make_viewport(self.map_image) self.level_surface = self.make_level_surface(self.map_image) self.level_rect = self.level_surface.get_rect() - self.player = None self.portals = None - self.player = person.Player(game_data['last direction']) self.player = self.make_player() self.blockers = self.make_blockers() self.sprites = self.make_sprites()

@@ -79,10 +77,11 @@ def make_player(self):

""" Make the player and sets location. """ - player = person.Player(self.game_data['last direction']) last_state = self.game_data['last state'] + if last_state == 'battle': + player = person.Player(self.game_data['last direction']) player.rect.x = self.game_data['last location'][0] * 32 player.rect.y = self.game_data['last location'][1] * 32

@@ -93,6 +92,7 @@ if properties['name'] == 'start point':

if last_state == properties['state']: posx = properties['x'] * 2 posy = (properties['y'] * 2) - 32 + player = person.Player(properties['direction']) player.rect.x = posx player.rect.y = posy
M data/tools.pydata/tools.py

@@ -1,6 +1,6 @@

__author__ = 'justinarmstrong' -import os +import os, random import pygame as pg from . import constants as c

@@ -175,7 +175,7 @@ player_items = {'GOLD': dict([('quantity',600),

('value',0)]), 'Healing Potion': dict([('quantity',5), ('value',15)]), - 'Fire Blast': dict([('magic points', 75), + 'Fire Blast': dict([('magic points', 25), ('power', 10)]), 'Cure': dict([('magic points', 25), ('power', 50)])}

@@ -202,7 +202,8 @@ ('value',0)])},

'old man item': {'ELIXIR': dict([('value',1000), ('quantity',1)])}, 'player inventory': player_items, - 'player stats': player_stats + 'player stats': player_stats, + 'battle counter': random.randint(50, 255) } return data_dict
M resources/tmx/brotherhouse.tmxresources/tmx/brotherhouse.tmx

@@ -86,6 +86,7 @@ </properties>

</object> <object name="start point" gid="123" x="192" y="224"> <properties> + <property name="direction" value="up"/> <property name="state" value="overworld"/> </properties> </object>
M resources/tmx/castle.tmxresources/tmx/castle.tmx

@@ -19,6 +19,7 @@ </layer>

<objectgroup name="Object Layer 1" width="25" height="27"> <object name="start point" gid="73" x="192" y="416"> <properties> + <property name="direction" value="up"/> <property name="state" value="town"/> </properties> </object>
M resources/tmx/dungeon.tmxresources/tmx/dungeon.tmx

@@ -14,6 +14,7 @@ </layer>

<objectgroup name="Object Layer 1" width="25" height="27"> <object name="start point" gid="73" x="192" y="416"> <properties> + <property name="direction" value="up"/> <property name="state" value="overworld"/> </properties> </object>

@@ -108,12 +109,14 @@ <object name="blocker" gid="70" x="304" y="160"/>

<object name="portal" type="dungeon2" gid="89" x="48" y="96"/> <object name="start point" gid="73" x="48" y="112"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon2"/> </properties> </object> <object name="portal" type="dungeon4" gid="89" x="336" y="96"/> <object name="start point" gid="73" x="336" y="112"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon4"/> </properties> </object>
M resources/tmx/dungeon2.tmxresources/tmx/dungeon2.tmx

@@ -8,16 +8,17 @@ <image source="../graphics/tileset3.png" width="176" height="192"/>

</tileset> <layer name="Tile Layer 1" width="25" height="25"> <data encoding="base64" compression="zlib"> - eJzdlFsKACAIBL3/gTxfvyIimrtRCUGQzvSQRP4LdYPBUJc3cVheZw8dR3YOtiPK3eGzalBvyOBXGAh+xkLyPXPae7c4/JzhYJ0j4rN7qrKG4CM8rL9kctfV2lMOKeRlDsuZ7AVd+0IsUh5T5Q== + eJzdlEEOABAMBPv/B3H2M1dppFm6K2jipJ1RGmb/RXFLwSguL+MYeStnWHFEfagds9wdvqqG9YYKPsJg8CMWk++Z2dm7xVEPOFR9zPjqmUL2GHyGR/WXZO4arT3lMCAvcjTAoe7j1eh1OlVd </data> </layer> <objectgroup name="Object Layer 1" width="25" height="25"> - <object name="start point" gid="73" x="208" y="240"> + <object name="start point" gid="73" x="64" y="80"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon"/> </properties> </object> - <object name="portal" type="dungeon" gid="89" x="208" y="224"/> + <object name="portal" type="dungeon" gid="89" x="64" y="64"/> <object name="blocker" gid="70" x="256" y="224"/> <object name="blocker" gid="70" x="256" y="192"/> <object name="blocker" gid="70" x="256" y="208"/>

@@ -125,7 +126,15 @@ <object name="blocker" gid="70" x="256" y="240"/>

<object name="portal" type="dungeon3" gid="89" x="352" y="64"/> <object name="start point" gid="73" x="352" y="80"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon3"/> + </properties> + </object> + <object name="portal" type="dungeon4" gid="89" x="80" y="352"/> + <object name="start point" gid="73" x="80" y="368"> + <properties> + <property name="direction" value="down"/> + <property name="state" value="dungeon4"/> </properties> </object> </objectgroup>
M resources/tmx/dungeon3.tmxresources/tmx/dungeon3.tmx

@@ -14,16 +14,18 @@ <data encoding="base64" compression="zlib">

eJztz80KgkAYheG5wmgpLaN9plaklT94F1r2cw+51ivzXYwwiAuhiSi+Aw8z3+pwlPpu1nCxgQcfAbbYYY/Dmx0hIhxxwhkxEqTIkP9IR4NWvzPMjbu11PFCrV8HC+OuLXWYO/oO2THeITumd8iO6R3/uGOJlfrsjj42dxQoccEVFW6444Gn/kskw3Q16m94 </data> </layer> - <objectgroup name="Object Layer 1" width="25" height="25" visible="0"> + <objectgroup name="Object Layer 1" width="25" height="25"> <object name="portal" type="dungeon2" gid="89" x="176" y="304"/> <object name="portal" type="dungeon4" gid="89" x="192" y="304"/> <object name="start point" gid="73" x="176" y="288"> <properties> + <property name="direction" value="up"/> <property name="state" value="dungeon2"/> </properties> </object> <object name="start point" gid="73" x="192" y="288"> <properties> + <property name="direction" value="up"/> <property name="state" value="dungeon4"/> </properties> </object>
M resources/tmx/dungeon4.tmxresources/tmx/dungeon4.tmx

@@ -8,13 +8,14 @@ <image source="../graphics/tileset3.png" width="176" height="192"/>

</tileset> <layer name="Tile Layer 1" width="25" height="25"> <data encoding="base64" compression="zlib"> - eJxjYBhcYBsSHrWDOHtoDQarHaSGMbl2kKKXUn8Q4x9qxMdA20Gt/IEt7NDNJkYNNezHp4ZSMNDxBZOnNOxIyUfDwQ5KwHCwY7jUtfSqz8kBAIuDOCs= + eJxjYBhcYBsSpqUdyDSt7KC1P2D20BoMVjtIDWNy7SBFL6X+IMY/1IiPgbaDWvkDW9gh44NEqKGW/fjUUAoGOr5g8pSGHan5iNZ20NoflIDhYAe96vPhYAe5AAC7pDeA </data> </layer> <objectgroup name="Object Layer 1" width="25" height="25"> - <object name="portal" type="dungeon" gid="89" x="192" y="208"/> - <object name="start point" gid="73" x="192" y="224"> + <object name="portal" type="dungeon" gid="89" x="368" y="272"/> + <object name="start point" gid="73" x="368" y="288"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon"/> </properties> </object>

@@ -125,5 +126,18 @@ <object name="blocker" gid="70" x="208" y="176"/>

<object name="blocker" gid="70" x="400" y="256"/> <object name="blocker" gid="70" x="400" y="272"/> <object name="blocker" gid="70" x="400" y="288"/> + <object name="start point" gid="73" x="16" y="160"> + <properties> + <property name="direction" value="down"/> + <property name="state" value="dungeon3"/> + </properties> + </object> + <object name="portal" type="dungeon2" gid="89" x="192" y="48"/> + <object name="start point" gid="73" x="192" y="64"> + <properties> + <property name="direction" value="down"/> + <property name="state" value="dungeon2"/> + </properties> + </object> </objectgroup> </map>
M resources/tmx/house.tmxresources/tmx/house.tmx

@@ -40,6 +40,7 @@ </properties>

</object> <object name="start point" gid="123" x="176" y="224"> <properties> + <property name="direction" value="up"/> <property name="state" value="town"/> </properties> </object>
M resources/tmx/overworld.tmxresources/tmx/overworld.tmx

@@ -154,22 +154,26 @@ <object name="portal" type="town" gid="139" x="272" y="480"/>

<object name="portal" type="town" gid="139" x="256" y="480"/> <object name="start point" gid="123" x="272" y="496"> <properties> + <property name="direction" value="down"/> <property name="state" value="town"/> </properties> </object> <object name="start point" gid="123" x="256" y="496"> <properties> + <property name="direction" value="down"/> <property name="state" value="main menu"/> </properties> </object> <object name="portal" type="brotherhouse" gid="139" x="400" y="144"/> <object name="start point" gid="123" x="400" y="160"> <properties> + <property name="direction" value="down"/> <property name="state" value="brotherhouse"/> </properties> </object> <object name="start point" gid="123" x="80" y="128"> <properties> + <property name="direction" value="down"/> <property name="state" value="dungeon"/> </properties> </object>
M resources/tmx/town.tmxresources/tmx/town.tmx

@@ -46,6 +46,7 @@ </layer>

<objectgroup name="Object Layer 1" width="25" height="51"> <object name="start point" gid="123" x="176" y="800"> <properties> + <property name="direction" value="up"/> <property name="state" value="overworld"/> </properties> </object>

@@ -231,31 +232,37 @@ <object name="portal" type="potion shop" gid="139" x="288" y="368"/>

<object name="portal" type="magic shop" gid="139" x="352" y="368"/> <object name="start point" gid="123" x="320" y="688"> <properties> + <property name="direction" value="down"/> <property name="state" value="Inn"/> </properties> </object> <object name="start point" gid="123" x="64" y="704"> <properties> + <property name="direction" value="down"/> <property name="state" value="house"/> </properties> </object> <object name="start point" gid="123" x="352" y="384"> <properties> + <property name="direction" value="down"/> <property name="state" value="magic shop"/> </properties> </object> <object name="start point" gid="123" x="288" y="384"> <properties> + <property name="direction" value="down"/> <property name="state" value="potion shop"/> </properties> </object> <object name="start point" gid="123" x="96" y="384"> <properties> + <property name="direction" value="down"/> <property name="state" value="armor shop"/> </properties> </object> <object name="start point" gid="123" x="32" y="384"> <properties> + <property name="direction" value="down"/> <property name="state" value="weapon shop"/> </properties> </object>

@@ -389,11 +396,13 @@ <object name="portal" type="castle" gid="139" x="176" y="112"/>

<object name="portal" type="castle" gid="139" x="192" y="112"/> <object name="start point" gid="123" x="192" y="128"> <properties> + <property name="direction" value="down"/> <property name="state" value="castle"/> </properties> </object> <object name="start point" gid="123" x="176" y="128"> <properties> + <property name="direction" value="down"/> <property name="state" value="castle"/> </properties> </object>