これはStackOverflowの私の最初の投稿です。皆さんが初心者プログラマーを助けてくれることを願っています。それはPygame Pythonの簡単な質問です。Pygame、画面上で正方形を動かすが、前の動きを消去することはできない
私は画面上の四角形を移動しようとしていますが、前の動きを消去することはできません。
import pygame
pygame.init()
screen = pygame.display.set_mode((400,300))
pygame.display.set_caption("shield hacking")
JogoAtivo = True
GAME_BEGIN = False
# Speed in pixels per frame
x_speed = 0
y_speed = 0
cordX = 10
cordY = 100
def desenha():
quadrado = pygame.Rect(cordX, cordY ,50, 52)
pygame.draw.rect(screen, (255, 0, 0), quadrado)
pygame.display.flip()
while JogoAtivo:
for evento in pygame.event.get():
print(evento);
#verifica se o evento que veio eh para fechar a janela
if evento.type == pygame.QUIT:
JogoAtivo = False
pygame.quit();
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_SPACE:
print('GAME BEGIN')
desenha()
GAME_BEGIN = True;
if evento.key == pygame.K_LEFT and GAME_BEGIN:
speedX=-3
cordX+=speedX
desenha()
if evento.key == pygame.K_RIGHT and GAME_BEGIN:
speedX=3
cordX+=speedX
desenha()
を役に立てば幸い、あなたがORIGブリット前の表面に)(記入するか、それぞれの時間を持っている、またはようになります毎回新しいサーフェス。 – Dalen