def LoadSprites(self): """Load all of the sprites that we need""" """calculate the center point offset""" x_offset = (BLOCK_SIZE / 2) y_offset = (BLOCK_SIZE / 2) """Load the level""" level1 = level001.level() layout = level1.getLayout() img_list = level1.getSprites() """Create the Pellet group""" self.pellet_sprites = pygame.sprite.Group() """Create the block group""" self.block_sprites = pygame.sprite.Group() for y in xrange(len(layout)): for x in xrange(len(layout[y])): """Get the center point for the rects""" centerPoint = [(x * BLOCK_SIZE) + x_offset, (y * BLOCK_SIZE + y_offset)] if layout[y][x] == level1.BLOCK: block = basicSprite.Sprite(centerPoint, img_list[level1.BLOCK]) self.block_sprites.add(block) elif layout[y][x] == level1.SNAKE: self.snake = Snake(centerPoint, img_list[level1.SNAKE]) elif layout[y][x] == level1.PELLET: pellet = basicSprite.Sprite(centerPoint, img_list[level1.PELLET]) self.pellet_sprites.add(pellet) """Create the Snake group""" self.snake_sprites = pygame.sprite.RenderPlain((self.snake))
def LoadSprites(self): """Load all of the sprites that we need""" """calculate the center point offset""" x_offset = (BLOCK_SIZE / 2) y_offset = (BLOCK_SIZE / 2) """Load the level""" level1 = level001.level() layout = level1.getLayout() img_list = level1.getSprites() # > The pellet sprites are grouped # > The block sprites are grouped # > The Wall sprites are grouped # > This is an example of a style of Object Oriented Programming, assigning # > The groups of items as a bluprint of one object to save typing the # > same code over and over. self.pellet_sprites = pygame.sprite.Group() self.block_sprites = pygame.sprite.Group() self.gwall_sprites = pygame.sprite.Group() for y in xrange(len(layout)): for x in xrange(len(layout[y])): """Get the center point for the rects""" centerPoint = [(x * BLOCK_SIZE) + x_offset, (y * BLOCK_SIZE + y_offset)] if layout[y][x] == level1.BLOCK: self.block_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.BLOCK])) elif layout[y][x] == level1.GWALL: self.gwall_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.GWALL])) elif layout[y][x] == level1.SNAKE: self.snake = Snake(centerPoint, img_list[level1.SNAKE]) elif layout[y][x] == level1.PELLET: self.pellet_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.PELLET])) elif layout[y][x] == level1.GHOST: self.ghost = Ghost(centerPoint, img_list[level1.GHOST]) elif layout[y][x] == level1.GHOST2: self.ghost2 = Ghost(centerPoint, img_list[level1.GHOST2]) elif layout[y][x] == level1.GHOST3: self.ghost3 = Ghost(centerPoint, img_list[level1.GHOST3]) elif layout[y][x] == level1.GHOST4: self.ghost4 = Ghost(centerPoint, img_list[level1.GHOST4]) """Create the Snake group""" self.snake_sprites = pygame.sprite.RenderPlain((self.snake)) self.ghost_sprites = pygame.sprite.RenderPlain((self.ghost)) self.ghost2_sprites = pygame.sprite.RenderPlain((self.ghost2)) self.ghost3_sprites = pygame.sprite.RenderPlain((self.ghost3)) self.ghost4_sprites = pygame.sprite.RenderPlain((self.ghost4))
def LoadSprites(self): """Load all of the sprites that we need""" """calculate the center point offset""" x_offset = (BLOCK_SIZE / 2) y_offset = (BLOCK_SIZE / 2) """Load the level""" level1 = level001.level() layout = level1.getLayout() img_list = level1.getSprites() self.pellet_sprites = pygame.sprite.Group() self.block_sprites = pygame.sprite.Group() self.gwall_sprites = pygame.sprite.Group() for y in xrange(len(layout)): for x in xrange(len(layout[y])): """Get the center point for the rects""" centerPoint = [(x * BLOCK_SIZE) + x_offset, (y * BLOCK_SIZE + y_offset)] if layout[y][x] == level1.BLOCK: self.block_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.BLOCK])) elif layout[y][x] == level1.GWALL: self.gwall_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.GWALL])) elif layout[y][x] == level1.SNAKE: self.snake = Snake(centerPoint, img_list[level1.SNAKE]) elif layout[y][x] == level1.PELLET: self.pellet_sprites.add( basicSprite.Sprite(centerPoint, img_list[level1.PELLET])) elif layout[y][x] == level1.GHOST: self.ghost = Ghost(centerPoint, img_list[level1.GHOST]) elif layout[y][x] == level1.GHOST2: self.ghost2 = Ghost(centerPoint, img_list[level1.GHOST2]) elif layout[y][x] == level1.GHOST3: self.ghost3 = Ghost(centerPoint, img_list[level1.GHOST3]) elif layout[y][x] == level1.GHOST4: self.ghost4 = Ghost(centerPoint, img_list[level1.GHOST4]) """Create the Snake group""" self.snake_sprites = pygame.sprite.RenderPlain((self.snake)) self.ghost_sprites = pygame.sprite.RenderPlain((self.ghost)) self.ghost2_sprites = pygame.sprite.RenderPlain((self.ghost2)) self.ghost3_sprites = pygame.sprite.RenderPlain((self.ghost3)) self.ghost4_sprites = pygame.sprite.RenderPlain((self.ghost4))
def LoadSprites(self): '''Load the sprites that we need''' x_offset = BLOCK_SIZE / 2 y_offset = BLOCK_SIZE / 2 level1 = level001.level() layout = level1.getLayout() img_list = level1.getImages() self.pellet_sprites = pygame.sprite.RenderUpdates() self.block_sprites = pygame.sprite.RenderUpdates() self.super_pellet_sprites = pygame.sprite.RenderUpdates() self.monster_sprites = pygame.sprite.RenderUpdates() for y in range(len(layout)): for x in range(len(layout[y])): centerPoint = [(x * BLOCK_SIZE) + x_offset, (y * BLOCK_SIZE) + y_offset] if layout[y][x] == level1.block: block = basicSprite.Sprite(centerPoint, img_list[level1.block]) self.block_sprites.add(block) elif layout[y][x] == level1.pellet: pellet = basicSprite.Sprite(centerPoint, img_list[level1.pellet]) self.pellet_sprites.add(pellet) elif layout[y][x] == level1.snake: self.snake = Snake(centerPoint, img_list[level1.snake]) elif layout[y][x] == level1.monster: monster = Monster(centerPoint, img_list[level1.monster], img_list[level1.scared_monster]) self.monster_sprites.add(monster) elif layout[y][x] == level1.super_pellet: super_pellet = basicSprite.Sprite( centerPoint, img_list[level1.super_pellet]) self.super_pellet_sprites.add(super_pellet) self.snake_sprites = pygame.sprite.RenderUpdates((self.snake))
def LoadSprites(self): """Load all of the sprites that we need""" """Load textures""" img_list = self.level.getSprites() """Create the group of block sprites""" self.sprites_block = pygame.sprite.Group() """Create the group of pellet sprites""" self.sprites_pellet = pygame.sprite.Group() """Create the group of super-pellet sprites""" self.sprites_spellet = pygame.sprite.Group() """Create the group of npc sprites""" self.sprites_npc = pygame.sprite.Group() for y in range(len(self.layout)): for x in range(len(self.layout[y])): if self.layout[y][x][1] == self.level.BLOCK: block = basicSprite.Sprite(self.layout[y][x][0], img_list[self.level.BLOCK]) self.sprites_block.add(block) elif self.layout[y][x][1] == self.level.CHARACTER: self.character = Character(self.layout[y][x][0], img_list[self.level.CHARACTER]) elif self.layout[y][x][1] == self.level.PELLET: pellet = basicSprite.Sprite(self.layout[y][x][0], img_list[self.level.PELLET]) self.sprites_pellet.add(pellet) elif self.layout[y][x][1] == self.level.SPELLET: spellet = basicSprite.Sprite(self.layout[y][x][0], img_list[self.level.SPELLET]) self.sprites_spellet.add(spellet) elif self.layout[y][x][1] == self.level.NPC: self.npc = npc.NPC(self.layout[y][x][0], img_list[self.level.NPC]) self.sprites_npc.add(self.npc) """Create the Snake group""" self.sprites_character = pygame.sprite.RenderPlain(self.character)