I'm trying to create a game which includes a circle needing to be added after clicking somewhere, the other lines of code works fine, it is just the line of code pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)
that returns the error of:
TypeError: circle() takes no keyword arguments
Code:
import pygame
pygame.init()
white = (255, 255, 255)
player_details = []
circle_radius = 100
WIDTH = 500
HEIGHT = 500
win = pygame.display.set_mode((WIDTH, HEIGHT))
(irrelevant code here)
def insert_input(slot_num, marker):
board[slot_num] = marker
print(board)
def circle_placement(x, y):
if (31 <= x <= 179) and (31 <= y <= 179):
slot1 = 1
if board[1] == " ":
insert_input(slot1, player_details[1])
pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius
if board[1] != " ":
print("Turn passed for attempting to Cheat!")
(irrelevant code here)
I've tried other shapes and all work fine, it's just this that doesn't work and returns an error: TypeError: circle() takes no keyword arguments, I've tried to change 'circle_radius' to a number instead of the variable but that doesn't work and I've tried changing the colour and that doesn't work either.
I haven't found any answers from the inte.net, from what I have researched, and when I did, they did not work, so I am hoping to find answers here.
The radius argument of pygame.draw.circle()
is not a keyword argument (remove radius=
):
pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)
pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), circle_radius)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.