Modified overworld, can switch to begining from death scene.
Justin Armstrong justinmeister@gmail.com
Fri, 13 Jun 2014 10:56:05 -0700
4 files changed,
52 insertions(+),
23 deletions(-)
M
data/states/death.py
→
data/states/death.py
@@ -18,9 +18,9 @@ def __init__(self):
super(Arrow, self).__init__() self.image = setup.GFX['smallarrow'] self.rect = self.image.get_rect(x=300, - y=550) + y=532) self.index = 0 - self.pos_list = [100, 200] + self.pos_list = [532, 566] def update(self, keys): """@@ -58,7 +58,7 @@ self.state_dict = self.make_state_dict()
self.state = c.TRANSITION_IN self.alpha = 255 self.name = c.DEATH_SCENE - self.transition_surface = copy.copy(self.background) + self.transition_surface = pg.Surface(setup.SCREEN_RECT.size) self.transition_surface.fill(c.BLACK_BLUE) self.transition_surface.set_alpha(self.alpha)@@ -105,15 +105,15 @@ c.NORMAL: self.normal_update}
return state_dict - def update(self, surface, *args): + def update(self, surface, keys, *args): """ Update scene. """ update_level = self.state_dict[self.state] - update_level() + update_level(keys) self.draw_level(surface) - def transition_in(self): + def transition_in(self, *args): """ Transition into scene with a fade. """@@ -123,19 +123,31 @@ if self.alpha <= 0:
self.alpha = 0 self.state = c.NORMAL - def transition_out(self): + def transition_out(self, *args): """ Transition out of scene with a fade. """ self.transition_surface.set_alpha(self.alpha) self.alpha += c.TRANSITION_SPEED if self.alpha >= 255: - self.game_data = pickle.load(open("save.p", "rb")) self.game_data['last state'] = self.name self.done = True - def normal_update(self): - pass + def normal_update(self, keys): + self.arrow.update(keys) + self.check_for_input(keys) + + def check_for_input(self, keys): + """ + Check if player wants to restart from last save point + or just start from the beginning of the game. + """ + if keys[pg.K_SPACE]: + if self.arrow.index == 0: + self.next = c.MAIN_MENU + elif self.arrow.index == 1: + self.next = c.MAIN_MENU + self.state = c.TRANSITION_OUT def draw_level(self, surface): """@@ -145,6 +157,7 @@ surface.blit(self.background, (0, 0))
surface.blit(self.player.image, self.player.rect) surface.blit(self.message_box.image, self.message_box.rect) surface.blit(self.arrow.image, self.arrow.rect) + surface.blit(self.transition_surface, (0, 0))
M
data/tools.py
→
data/tools.py
@@ -27,6 +27,7 @@ def setup_states(self, state_dict, start_state):
self.state_dict = state_dict self.state_name = start_state self.state = self.state_dict[self.state_name] + self.set_music() def update(self): self.current_time = pg.time.get_ticks()
M
resources/tmx/overworld.tmx
→
resources/tmx/overworld.tmx
@@ -17,7 +17,7 @@ <image source="../graphics/house1.png" width="16" height="16"/>
</tileset> <layer name="Tile Layer 1" width="30" height="37"> <data encoding="base64" compression="zlib"> - eJztls0KgCAQhH2ojJBC6hD9vP/7tAcPsqi4thtUe/hQuowzO8Q6Y4z7GR7YgS2cB7pPQrozcBZQ3Wd0z8zs42+4E6n70KDLwZLQ7QAL9AEJXew3hX3Ab0k7zoGqgzOs8ZtiZM60llUgU/Wrfin/NU6/lJw5/VJy5vRLyVn7rH2WyJl7J6vZB6T2wFLelLl6xJ2878wVvwPD5belXzYDZ4/fQE0/lO9zAVP6EKM= + eJztltEKwjAMRftRVmUoQx9E3f//jylMKCGNzZbbF/NwWBmDu3uTlEwppenPmIkX8Vyfb3a+gnRvxKIQumN0l0bt63e8J6TzeYOuB3dB90Bk4riC0OV+JfIAv5p2nYNVh2fY41fi4pxpLw9ApuE3/FruNU+/lpw9/Vpy9vRryTn6OfoZkbP3TtazD6D2QC1vS11nxp6899SV/wfHy++W/sqNWnv2sYY00/Uuj/Sv3SdI/0X31NBFzdQvz8icC6XH6z39ex7RZ625k779AFX2Eqc= </data> </layer> <layer name="Tile Layer 2" width="30" height="37">@@ -26,12 +26,12 @@ eJztzlkOglAAQ9G3/12oOAAyqDgwCjvjJuyhBNKbnO82BKfugCNOiIS7Z1xwxU24GyNBirtwN0OOAqVwd29Nax9wzjnn3GZ74IkXKuHuGx988RPu1mjQohPu9hjwxyjcdc4tzdmDFtI=
</data> </layer> <objectgroup name="Object Layer 1" width="30" height="37"> - <object name="blocker" gid="120" x="288" y="512"/> - <object name="blocker" gid="120" x="304" y="512"/> - <object name="blocker" gid="120" x="320" y="512"/> - <object name="blocker" gid="120" x="336" y="496"/> + <object name="blocker" gid="120" x="272" y="576"/> + <object name="blocker" gid="120" x="272" y="560"/> <object name="blocker" gid="120" x="336" y="480"/> + <object name="blocker" gid="120" x="336" y="496"/> <object name="blocker" gid="120" x="336" y="464"/> + <object name="blocker" gid="120" x="352" y="496"/> <object name="blocker" gid="120" x="336" y="448"/> <object name="blocker" gid="120" x="352" y="432"/> <object name="blocker" gid="120" x="368" y="416"/>@@ -47,8 +47,8 @@ <object name="blocker" gid="120" x="256" y="432"/>
<object name="blocker" gid="120" x="240" y="448"/> <object name="blocker" gid="120" x="240" y="464"/> <object name="blocker" gid="120" x="240" y="480"/> - <object name="blocker" gid="120" x="272" y="512"/> - <object name="blocker" gid="120" x="256" y="512"/> + <object name="blocker" gid="120" x="256" y="544"/> + <object name="blocker" gid="120" x="256" y="528"/> <object name="blocker" gid="120" x="240" y="512"/> <object name="blocker" gid="120" x="224" y="512"/> <object name="blocker" gid="120" x="208" y="512"/>@@ -158,7 +158,7 @@ <property name="direction" value="down"/>
<property name="state" value="town"/> </properties> </object> - <object name="start point" gid="123" x="256" y="368"> + <object name="start point" gid="123" x="368" y="560"> <properties> <property name="direction" value="down"/> <property name="state" value="main menu"/>@@ -179,5 +179,19 @@ </properties>
</object> <object name="portal" type="dungeon" gid="139" x="80" y="112"/> <object name="portal" type="dungeon" gid="139" x="64" y="112"/> + <object name="blocker" gid="120" x="352" y="592"/> + <object name="blocker" gid="120" x="320" y="592"/> + <object name="blocker" gid="120" x="304" y="592"/> + <object name="blocker" gid="120" x="288" y="592"/> + <object name="blocker" gid="120" x="336" y="592"/> + <object name="blocker" gid="120" x="368" y="592"/> + <object name="blocker" gid="120" x="384" y="592"/> + <object name="blocker" gid="120" x="368" y="496"/> + <object name="blocker" gid="120" x="384" y="496"/> + <object name="blocker" gid="120" x="400" y="512"/> + <object name="blocker" gid="120" x="400" y="528"/> + <object name="blocker" gid="120" x="400" y="544"/> + <object name="blocker" gid="120" x="400" y="560"/> + <object name="blocker" gid="120" x="400" y="576"/> </objectgroup> </map>