
So, in looking at the sprites for Mother Brain, I notice that she is put together very modularly. What I want to do as a sort of experiment is apply the various states of her animations in segments as opposed to blitting the whole sprite directly on. What I mean by this is instead of having frames for each permutation of her eye opened and closed, I just have a separate part for her eyes. Which if it goes well, I will separate her out entirely. So, updating the sheet leaves me with this:

In code, I'll work with the existing sheet plus this one. The change is pretty minor. We need to store the location of the eye in relation to the sprite, which is stored as the (col, row) location in the room. We need to store the eye images. I chose a dictionary so that the named states can be referenced. And then we store the state of Mother Brain, which I called awake. If she's awake, the eye is opened. Else it's closed.
self.eye_coord = (5,7)
self.eye = {
'opened': pygame.Surface((TILE_SIZE, TILE_SIZE)).convert(),
'closed': pygame.Surface((TILE_SIZE, TILE_SIZE)).convert()
}
self.eye['opened'].blit(self.eye_sheet, (0,0), (0, 0, 16, 16))
self.eye['closed'].blit(self.eye_sheet, (0,0), (16,0, 16, 16))
# When awake, eye is opened. Else, closed.
self.awake = False
After that, we simply draw based on her alertness
def draw(self, surface):
# -- snip prior drawing steps --
x, y = pixel_from_tile(self.eye_coord[0], self.eye_coord[1])
if self.awake:
surface.blit(self.eye['opened'], (x, y))
else:
surface.blit(self.eye['closed'], (x, y))
And her being awake or asleep is simply changed on a toggle method at the moment.










