如何在PyGame中绘制圆形?
问题描述:
嗨,我正在绘制一个圆的问题错误:“'模块'对象没有属性'circl'”我做错了什么?如何在PyGame中绘制圆形?
而且我怎样才能把数字放在圈子里? 例如:(第一次点击是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 <<<