This function detects if a gameobject has moved or has had its sprite changed. It then calls one of two functions (or none), to draw a piece of the games background over the gameobjects current location or previous location. Should functions like this be avoided? Is this good or bad design? Does it violate SRP?
Also, how would something like this be unit tested?
#clean up the display...
def blit_background_over_dirty_rects(self):
for gameobject, data in self.relevant_data.items():
if data['location'] != gameobject.rect.topleft: #gameobject moved...
self._blit_background_over_gameobjects_previous_location(gameobject)
elif data['sprite'] != gameobject.sprite_manager.current_sprite: #gameobjects sprite changed...
self._blit_background_over_gameobjects_current_location(gameobject)
↧