我有一个问题,不知道如何解释这个错误。我有一个要移动的图像,这是代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygame
import random
pygame.init()
size=[800,600]
screen=pygame.display.set_mode(size)
pygame.display.set_caption("Sub Dice")
background_position=[0,0]
background_image=pygame.image.load('Gfx/Table.png').convert()
card=pygame.image.load('Gfx/Deck1card01.png').convert_alpha()
card=pygame.transform.smoothscale(card,(130,182))
closeDeckShirt=pygame.image.load('Gfx/CardBack.png').convert_alpha()
SETFPS=30
zx=0
zy=0
done=False
clock=pygame.time.Clock()
while done==False:
clock.tick(SETFPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done=True
if event.type == pygame.MOUSEBUTTONDOWN:
print('a')
screen.blit(background_image, background_position)
screen.blit(card,[zx,zy])
zx=zx+2
zy=zy+2
pygame.display.flip()
pygame.quit ()
问题是卡片图像仅在我单击或移动鼠标时才会移动。如果我不触摸鼠标,图像就会静止。但应每帧移动一次(1/30 秒)。
谁能解释我做错了什么?