我在Sqlite3中建立了数据库,我读取了文件并从数据库中获取了所有用户,然后我想为每个用户画一个圆圈。因此,如果有三个用户,我想绘制三个彼此间隔约100像素的cicle。到目前为止,这就是我所拥有的:
with sqlite3.connect("root\\Users.db") as db:
cursor = db.cursor()
cursor.execute("SELECT * FROM users")
data = cursor.fetchall()
an = len(data)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
screen.fill(white)
for i in range(an):
pygame.draw.circle(screen, black, (dc,250), 77, 1)
pygame.display.flip()
答案 0 :(得分:0)
我会改变你的
for i in range(an):
pygame.draw.circle(screen, black, (dc, 250), 77, 1)
到
offset = 100 # change offset to whatever you want the offset to be
for i in range(an):
pygame.draw.circle(screen, black, (i*offset, 250), 77, 1)
但是,我要记住这段代码是从圆的中心到下一个圆的中心。为了使圆的边缘距离100px,您必须将圆的半径添加到offset变量中。看起来像:
radius = 77
offset = 100 + (2*radius) # change offset to whatever you want the offset to be
for i in range(an):
pygame.draw.circle(screen, black, (i*offset, 250), 77, 1)