How to use the pygame.draw.circle function in pygame

To help you get started, we’ve selected a few pygame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sparkslabs / kamaelia / Code / Python / Kamaelia / Examples / GraphVisualisation / BasicGraphVisualisation / PhysApp1.py View on Github external
def renderSelf(self, surface):
        """Renders a circle with the particle name in it"""
        pygame.draw.circle(surface, (255,128,128), (int(self.pos[0]), int(self.pos[1])), self.radius)
        surface.blit(self.label, (int(self.pos[0]) - self.label.get_width()/2, int(self.pos[1]) - self.label.get_height()/2))
github sseemayer / Py2D / examples / Math.py View on Github external
def draw_poly(self, poly, color):
		if len(poly) > 1:
			if self.fill and len(poly) > 2:
				pygame.draw.polygon(self.runner.screen, color, poly.as_tuple_list())
				pygame.draw.lines(self.runner.screen, 0x000000, True, poly.as_tuple_list())
			elif len(poly) > 1:
				pygame.draw.lines(self.runner.screen, color, True, poly.as_tuple_list())
		elif poly.points:
			pygame.draw.circle(self.runner.screen, color, poly.points[0].as_tuple(), 2)

		if self.debug:
			for p, c, t in self.debug_points:
				self.runner.screen.blit(self.runner.font.render(t, False, c), p.as_tuple())
github ShadowApex / DungeonTableMap / dungeon-table / core / fog.py View on Github external
def update(self, dt):
        pos = self.visible_position
        if pos[0] == -1:
            return

        player_surface = pygame.Surface(self.rect.size).convert_alpha()
        for i in range(220,0,-10):
            pygame.draw.circle(player_surface,(0,0,0,i),(int(pos[0]),int(pos[1])),int(i/220.0*10+90))
        pygame.draw.circle(player_surface,(0,0,0,0),(int(pos[0]),int(pos[1])),90)
        self.image.blit(player_surface,(0,0),special_flags=pygame.BLEND_RGBA_MIN)
        pygame.draw.circle(self.visible_area, (255, 0, 0), (int(pos[0]), int(pos[1])), 80)
        self.mask = pygame.mask.from_surface(self.visible_area)
github realkushagrakhare / 3D_Path_Planning / rrt-star_ReedsSheep_New.py View on Github external
Draw Graph
        """
        reset()
        if rnd is not None:
            plt.plot(rnd.x, rnd.y, "^k")
        for node in self.nodeList:
            if node.parent is not None:
                plt.plot(node.path_x, node.path_y, "-g")
                for i in range(1, len(node.path_x)):
                    pygame.draw.line(screen,blue,(node.path_x[i-1], node.path_y[i-1]), (node.path_x[i], node.path_y[i]))
                #  plt.plot([node.x, self.nodeList[node.parent].x], [
                #  node.y, self.nodeList[node.parent].y], "-g")

        for (ox, oy, size) in self.obstacleList:
            #plt.plot(ox, oy, "ok", ms=30 * size)
            pygame.draw.circle(screen, black, (ox, oy), size)

        '''reeds_shepp_path_planning.plot_arrow(self.start.x, self.start.y, self.start.yaw)
        reeds_shepp_path_planning.plot_arrow(self.end.x, self.end.y, self.end.yaw)'''
        pygame.draw.circle(screen, red, (self.start.x, self.start.y), GOAL_RADIUS)
        pygame.draw.circle(screen, green, (self.end.x, self.end.y), GOAL_RADIUS)

        '''plt.axis([-2, 15, -2, 15])
        plt.grid(True)
        plt.pause(0.01)'''
        pygame.display.update()
        #  plt.show()
github NITDgpOS / AirHockey / paddle.py View on Github external
def draw(self, screen, color):
        position = (int(self.x), int(self.y))

        pygame.draw.circle(screen, color, position, self.radius, 0)
        pygame.draw.circle(screen, (0, 0, 0), position, self.radius, 2)
        pygame.draw.circle(screen, (0, 0, 0), position, self.radius - 5, 2)
        pygame.draw.circle(screen, (0, 0, 0), position, self.radius - 10, 2)
github kidscancode / gamedev / tutorials / examples / steering / part03.py View on Github external
def draw_vectors(self):
        scale = 25
        # vel
        pg.draw.line(screen, GREEN, self.pos, (self.pos + self.vel * scale), 5)
        # desired
        pg.draw.line(screen, RED, self.pos, (self.pos + self.desired * scale), 5)
        # flee radius
        pg.draw.circle(screen, WHITE, pg.mouse.get_pos(), FLEE_DISTANCE, 1)
github reinforcement-learning-kr / alpha_omok / 2. omok / Human_vs_Human / large_omok.py View on Github external
mainboard_rect = pygame.Rect(MARGIN, TOP_MARGIN, WINDOW_WIDTH - 2 * MARGIN, WINDOW_WIDTH - 2 * MARGIN)
    pygame.draw.rect(DISPLAYSURF, BADUK, mainboard_rect)

    # Horizontal Lines
    for i in range(GAMEBOARD_SIZE):
        pygame.draw.line(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN, TOP_MARGIN + BOARD_MARGIN + i * int(GRID_SIZE/(GAMEBOARD_SIZE-1))), (WINDOW_WIDTH - (MARGIN + BOARD_MARGIN), TOP_MARGIN + BOARD_MARGIN + i * int(GRID_SIZE/(GAMEBOARD_SIZE-1))), 1)

    # Vertical Lines
    for i in range(GAMEBOARD_SIZE):
        pygame.draw.line(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN + i * int(GRID_SIZE/(GAMEBOARD_SIZE-1)), TOP_MARGIN + BOARD_MARGIN), (MARGIN + BOARD_MARGIN + i * int(GRID_SIZE/(GAMEBOARD_SIZE-1)), TOP_MARGIN + BOARD_MARGIN + GRID_SIZE), 1)

    # Draw center circle
    for i in range(GAMEBOARD_SIZE):
        for j in range(GAMEBOARD_SIZE):
            if i in [3, 9, 15] and j in [3, 9, 15]:
                pygame.draw.circle(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN + i * int(GRID_SIZE/(GAMEBOARD_SIZE-1)), TOP_MARGIN + BOARD_MARGIN + j * int(GRID_SIZE/(GAMEBOARD_SIZE-1))), 5, 0)

    # Draw stones
    for i in range(gameboard.shape[0]):
        for j in range(gameboard.shape[1]):
            if gameboard[i,j] == 1:
                pygame.draw.circle(DISPLAYSURF, BLACK, (X_coord[j], Y_coord[i]), 15, 0)

            if gameboard[i,j] == -1:
                pygame.draw.circle(DISPLAYSURF, WHITE, (X_coord[j], Y_coord[i]), 15, 0)
github uthcode / learntosolveit / games / nanho / slide1.py View on Github external
def draw_ball(screen, ball):
    p = int(ball.body.position.x), 600 - int(ball.body.position.y)
    pygame.draw.circle(screen, THECOLORS["tomato2"], p, int(ball.radius), 0)
github artsimboldo / sugarscape / sugarscape.py View on Github external
def draw(self):
        self.screen.fill(colorBackground)

        # display sugarscape
        for i, j in product(range(env.gridHeight), range(env.gridWidth)):
            x = i * self.siteSize
            y = j * self.siteSize
            # display sugar's capacity
            capacity = env.getCapacity((i,j))
            if capacity > 0:
                pygame.draw.rect(self.screen, colorSugar[capacity - 1], (x, y, self.siteSize - 1, self.siteSize - 1))

            # Draw agent if any
            agent = env.getAgent((i, j))
            if agent:
                pygame.draw.circle(self.screen,
                                    # select color scheme
                                    self.agentColorSchemes.get(agentColorScheme)(self, agent), 
                                    (x + self.radius, y + self.radius), 
                                    self.radius - 1)

        pygame.display.flip()
github carla-simulator / carla / PythonAPI / no_rendering_mode.py View on Github external
def make_surface(tl):
            w = 40
            surface = pygame.Surface((w, 3 * w), pygame.SRCALPHA)
            surface.fill(COLOR_ALUMINIUM_5 if tl != 'h' else COLOR_ORANGE_2)
            if tl != 'h':
                hw = int(w / 2)
                off = COLOR_ALUMINIUM_4
                red = COLOR_SCARLET_RED_0
                yellow = COLOR_BUTTER_0
                green = COLOR_CHAMELEON_0
                pygame.draw.circle(surface, red if tl == tls.Red else off, (hw, hw), int(0.4 * w))
                pygame.draw.circle(surface, yellow if tl == tls.Yellow else off, (hw, w + hw), int(0.4 * w))
                pygame.draw.circle(surface, green if tl == tls.Green else off, (hw, 2 * w + hw), int(0.4 * w))
            return pygame.transform.smoothscale(surface, (15, 45) if tl != 'h' else (19, 49))
        self._original_surfaces = {