You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
move_monsters doesn't really belong in the map object. Move should really be a method of the Monster class. That way, thanks to duck typing each monster could potentially have different behaviour.
The movement could then be called within the game loop:
Also... monsters, treasures etc probably shouldn't have their own map objects to keep track of them, and you shouldn't have to loop through every square on the map just to find your monsters. It would be preferable if each monster keeps track of it's own coordinates on the map. That way you could keep track of whether there is a monster on a given map square just like this:
# check if a square (x, y) is occupied by a monstermonsters_on_square= [mforminmonsters_on_levelifm.coords== (x, y)]
# or if we know that only one monster is allowed per square:monster_on_square= [mforminmonsters_on_levelifm.coords== (x, y)][0]
Regarding that last comment, I know it is probably desirable to have one monster per square, but it is probably OK to have multiple treasures occupy the same square.
The text was updated successfully, but these errors were encountered:
move_monsters doesn't really belong in the map object. Move should really be a method of the Monster class. That way, thanks to duck typing each monster could potentially have different behaviour.
The movement could then be called within the game loop:
Also monsters could possibly take care of drawing themselves as well:
Also... monsters, treasures etc probably shouldn't have their own map objects to keep track of them, and you shouldn't have to loop through every square on the map just to find your monsters. It would be preferable if each monster keeps track of it's own coordinates on the map. That way you could keep track of whether there is a monster on a given map square just like this:
Regarding that last comment, I know it is probably desirable to have one monster per square, but it is probably OK to have multiple treasures occupy the same square.
The text was updated successfully, but these errors were encountered: