gpt4 book ai didi

python - 如何在 PyGame 中画一个圆圈?

转载 作者:行者123 更新时间:2023-12-03 18:37:50 26 4
gpt4 key购买 nike

嗨,我在画圆时遇到问题 ERROR: module object has no attribute 'circle' .我究竟做错了什么?

还有我怎样才能把数字圈起来?

例如:(第一次点击是0的圆圈,第二次是1的圆圈等等)

import pygame

WHITE = (255, 255, 255)
BLUE = ( 0, 0, 255)
GREEN = ( 0, 255, 0)
RED = (255, 0, 0)
TEXTCOLOR = ( 0, 0, 0)
(width, height) = (200, 300)

running = True

def main():
global running, screen

pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("TUFF")
screen.fill(background_color)
pygame.display.update()

while running:
ev = pygame.event.get()

for event in ev:

if event.type == pygame.MOUSEBUTTONUP:
drawCircle()
pygame.display.update()

if event.type == pygame.QUIT:
running = False

def getPos():
pos = pygame.mouse.get_pos()
return (pos)

def drawCircle():
pos=getPos()
pygame.draw.circl(screen, BLUE, pos, 20)


if __name__ == '__main__':
main()

最佳答案

您输入了错误的函数名称。正确的名称是 pygame.draw.circle .

def drawCircle():
pos=getPos()
pygame.draw.circle(screen, BLUE, pos, 20) # Here <<<

关于python - 如何在 PyGame 中画一个圆圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46843897/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com