~wolterh/dwarfbomber/main

Viewing all changes in revision 33.

  • Committer: dan737
  • Date: 2011-05-17 15:27:28 UTC
  • Revision ID: git-v1:94c9c0f3b15b329222c9fa3f5593346df308a517
Improved the tileLayer of the gameMap class. Optimized the SortedGroup class. Added a TileLayer class.

The tileLayer was ineffective. Every frame, the engine had to blit every individual tile on the screen. Because this tileLayer is mostly static, a huge improvement can be achieved by creating a pygame.Surface on which we blit once and for all the different tiles constituing the floor. So I create a new class TileLayer which holds a pygame.Surface the size of the level and which has a draw method to draw itself onto the camera. In the gameMap, the self.tileLayer holds now an instance of this class, and the method add_tile(self, position, tileType="floor") blit the new tile on the tileLayer's surface.

SortedGroup class was sorting its sprites any time the class was requesting the sprites in that group. But this sorting is only required for drawing, not for updating. So the sorting is now only happening in the draw method, making sprites retrieval much faster when calling the update method.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: