我有一条蛇正在转弯并在他身后绘制轨迹,但我不知道如何在他绘制时像随机停顿一样打孔。我试过了,它不是随机的,但问题是它的暂停非常快。这就像传送动作。这是我的代码:
import pygame
pygame.init()
import random
from random import randint
win = pygame.display.set_mode((1280,720))
background = pygame.Surface(win.get_size(), pygame.SRCALPHA)
background.fill((0, 0, 0, 1))
x = randint(150,1130)
y = randint(150,570)
vel = 0.6
drawing_time = 0
direction = pygame.math.Vector2(vel, 0).rotate(random.randint(0, 360))
run = True
while run:
pygame.time.delay(5)
drawing_time += 1
if drawing_time == 1000:
for pause in range(0, 60):
head = pygame.draw.circle(win, (255,0,0), (round(x), round(y)), 0)
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
direction.rotate_ip(-0.8)
if keys[pygame.K_RIGHT]:
direction.rotate_ip(0.8)
x += direction.x
y += direction.y
time = 0
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
direction.rotate_ip(-0.8)
if keys[pygame.K_RIGHT]:
direction.rotate_ip(0.8)
x += direction.x
y += direction.y
win.blit(background, (12020,0))
head= pygame.draw.circle(win, (255,0,0), (round(x), round(y)), 5)
pygame.display.update()
pygame.quit()
我试图将头部半径设为 0,也许这是个问题,但我不知道如何解决它。