Re: Another question again, still Python, yea?
I don't think your particularly over thinking it, if you plan on having different victory conditions per map you may have no choice but to have a separate progression trigger for each. I think the term your looking for is abstraction or compartmentalization, which is fine from a design stand point to make code more easy to manage. Another way of dealing with it would be to use classes for each map with their own independant function handlers, including victory conditions. For example:
class lev1(object):
def __init__(self):
#our map data
self.data = ""
#current number of enemies
self.enemies = 0
def update(self,player): #update map things, changes to the environment, player position, etc. #if all enemies defeated, advance to next level if self.enemies == 0: print('enemies defeated!') player.level += 1 class lev2(object): def __init__(self): #our map data self.data = "" def update(self,player): #update map things #player is at position of exit, advance level if self.data[player.y][player.x] == 99: print('player at exit!') player.level += 1 class player(object): def __init__(self): self.x = 2 self.y = 1 self.level = 0 class main(object): def __init__(self): self.levels = [lev1(),lev2()] self.player = player() #main update loop def update(self): while True: #update level and pass the player to it self.levels[self.player.level].update(self.player) if self.player.level == 2: print('victory!') break a = main() a.update()
In the given example, the main class loads each map class, then passes the player class and iterates over them but lets the map classes handle things for themselves internally. When their conditions are met they change the player state which switches the map over to the next map handler class with different conditions.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector