Ejemplo n.º 1
0
 def __init__(self, game_map, position):
     """Place a circular notification on the map that will disappear after
     *timeout* milliseconds
     """
     position = Point(position.x, position.y, 1000) - (Point(Ping.RADIUS, Ping.RADIUS) * (float(game_map._scale) / 16))
     Painter.__init__(self, game_map, Point(Ping.RADIUS * 2 / (float(game_map._scale) / 16), Ping.RADIUS * 2 / (float(game_map._scale) / 16)), position)
     self.__age = 0 # in ms
Ejemplo n.º 2
0
 def __init__(self, game_map, position):
     # Place a human on the map
     position = Point(position.x, position.y, 5) - (Point(Human.WIDTH / 2, Human.HEIGHT / 2) * game_map._scale)
     self._scale = 16
     surface = pygame.Surface((Human.WIDTH * self._scale, Human.HEIGHT * self._scale)).convert_alpha()
     top = (Human.WIDTH * self._scale / 2, 0)
     left = (0, Human.HEIGHT * self._scale)
     right = (Human.WIDTH * self._scale, Human.HEIGHT * self._scale)
     pygame.draw.polygon(surface, Human.COLOR, (top, left, right), 1)
     
     Painter.__init__(self, game_map, Point(Human.WIDTH, Human.HEIGHT), position, surface)
     Human.all.append(self)
     self._direction = 0
     self._target = None
Ejemplo n.º 3
0
    def __init__(self, view_size, parent_painter):
        self._log = logging.getLogger("map")
        print "building mountains"
        terrain = pygame.image.load(os.path.abspath(os.path.join("media", "PerlinNoise2d.png"))).convert()
        self.coordinates = []
        terrain_array = pygame.surfarray.pixels2d(terrain)
        for x in xrange(0, len(terrain_array)):
            self.coordinates.append([])
            for y in xrange(0, len(terrain_array[x])):
                h, s, v, a = terrain.unmap_rgb(terrain_array[x][y]).hsva
                if v < 50: # water
                    self.coordinates[x].append(False)
                    terrain_array[x][y] = terrain.map_rgb(70 - (50 - v), 70 - (50 - v), 100 + v * 2)
                else: # land
                    self.coordinates[x].append(True)
                    terrain_array[x][y] = terrain.map_rgb(70 - v * 0.1, v * 1.5, 40 + v * 0.3)

        print "digging oceans"
        surface = pygame.transform.scale(terrain, (terrain.get_width() * 16, terrain.get_height() * 16))
        Painter.__init__(self, parent_painter, Point(0,0), Point(0,0,0), surface, Point(0,0))
Ejemplo n.º 4
0
 def __init__(self, parent_painter, size = Point(0, 0), relative_position = Point(0, 0, 1000), surface = None):
     Painter.__init__(self, parent_painter, size, relative_position, surface)
     pygame.time.set_timer(UPDATE_FPS_PAINTER_EVENT, 1000)