Найти - Пользователи
Полная версия: pygame анимация
Начало » Python для новичков » pygame анимация
1
Khudya
как нормально сделать движение прямоугольника. Сейчас он двигается, но у него остается “след” то есть его предыдущее изображение не стирается.
как-то так код выглядит сейчас


import pygame
from random import randrange as rnd
width, height = 1200, 800
fps = 60
plot_w = 330
plot_h = 35
plot_l = width // 2 - plot_w // 2
plot_r = height - plot_h - 100
pl_speed = 15
plot = pygame.Surface((330, 35))
plot.fill('RED')
pygame.init()
sc = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()

while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
sc.blit(plot, (plot_l, plot_r))
key = pygame.key.get_pressed()
if key and plot_l>0:
plot_l -= pl_speed
if key and plot_r<width:
plot_r += pl_speed
if key and plot_l<width:
plot_l += pl_speed
if key and plot_r<width:
plot_r -= pl_speed

pygame.display.update()
clock.tick(fps)
doza_and
А где у вас
  screen.fill(BLACK)
pygame.display.flip()
https://pythonru.com/uroki/biblioteka-pygame-chast-1-vvedenie
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB