为什么管道在接触窗口的开头时不会移动到末端?
import pygame
pygame.init()
sc = pygame.display.set_mode((700,800))
pygame.display.set_caption("Flappy Bird")
FPS = 30
clock = pygame.time.Clock()
x = 350
y = 400
xOfDuct = 732
yOfDuct = 800
flag = 0
def duct():
ductOne_surf = pygame.image.load('trubaDown.png')
ductOne_surf = pygame.transform.scale(ductOne_surf, (120,452))
ductOne_rect = ductOne_surf.get_rect(bottomright=(xOfDuct,yOfDuct))
sc.blit(ductOne_surf,ductOne_rect)
def ductTwo():
duct_surf = pygame.image.load('trubaUp.png')
duct_surf = pygame.transform.scale(duct_surf, (120,452))
duct_rect = duct_surf.get_rect(bottomright=(xOfDuct, yOfDuct - yOfDuct + 175))
sc.blit(duct_surf,duct_rect)
while True:
sc.fill((255,255,255))
duct()
ductTwo()
pygame.draw.circle(sc, (255,255,0),(x,y),20)
for i in pygame.event.get():
if i.type == pygame.QUIT:
exit()
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
flag = 0
y-=15
if xOfDuct == 0:
xOfDuct = 700
flag+=2
y+=flag
xOfDuct -= 10
pygame.display.update()
clock.tick(FPS)
你
xOfDuct
的等于732
,每一步减少十如我们所见,
xOfDuct
它只是跳转0
并if
没有执行,所以==
我们需要替换<