简体   繁体   English

错误:TypeError: circle() 没有关键字 arguments

[英]Error: TypeError: circle() takes no keyword arguments

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:我正在尝试创建一个游戏,其中包含一个需要在单击某处后添加的圆圈,其他代码行工作正常,它只是代码行pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)返回的错误为:

 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.我尝试了其他形状并且一切正常,只是这个不起作用并返回错误:TypeError: circle() takes no keyword arguments,我试图将“circle_radius”更改为数字而不是变量但这不起作用,我尝试更改颜色但也不起作用。

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.我还没有从 inte.net 上找到任何答案,从我的研究中,当我这样做的时候,他们没有工作,所以我希望在这里找到答案。

The radius argument of pygame.draw.circle() is not a keyword argument (remove radius= ):pygame.draw.circle()半径参数不是关键字参数(删除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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM