Example #1
0
    def enqueue_shadow(self, screen):
        """Add it's own shadow to the list of shadows that the ground have to
        paint.
        """
        min_depth = int(self.pos[2])-1
        tile_y, tile_x = int(self.pos[0]), int(self.pos[1])

        if (self.pos[0] < 0.0 or self.pos[0] >= len(Ground.pattern[0]) or
            self.pos[1] < 0.0 or self.pos[1] >= len(Ground.pattern[0][0])):
            return

        while min_depth < len(Ground.pattern):
            if not Ground.pattern[min_depth][tile_x][tile_y]:
                min_depth += 1
                continue

            shadow_pos = self.pos[:]
            shadow_pos[2] = len(Ground.pattern) - min_depth + 0.3

            # The shadow behaves different if there is a slope.
            if Ground.pattern[min_depth][tile_x][tile_y]==2:
                shadow_pos[2] += self.pos[0]-tile_y
            elif Ground.pattern[min_depth][tile_x][tile_y]==3:
                shadow_pos[2] += self.pos[1]-tile_x
            elif Ground.pattern[min_depth][tile_x][tile_y]==4:
                shadow_pos[2] -= self.pos[0]-tile_y-1
            elif Ground.pattern[min_depth][tile_x][tile_y]==5:
                shadow_pos[2] -= self.pos[1]-tile_x-1

            Ground.add_shadow(screen, shadow_pos, min_depth, self.radius)

            min_depth += 1