Advertisement
niromru

Спрайты ---> Машинки

Jan 26th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import urllib.request
  2. import pygame
  3. from time import sleep
  4.  
  5. f, h = urllib.request.urlretrieve('https://yastatic.net/s3/lyceum/content/image/pygame/car2.png')
  6. img = open(f)
  7. if __name__ == '__main__':
  8.     pygame.init()
  9.     x, y = 0, 0
  10.     size = width, height = 600, 95
  11.     sc = pygame.display.set_mode(size)
  12.     imgp = pygame.image.load(img)
  13.     d = 0
  14.     while True:
  15.         sc.fill((255, 255, 255))
  16.         sc.blit(imgp, (x, 0))
  17.         sleep(0.01)
  18.         pygame.display.update()
  19.         if x > 450:
  20.             d = 1
  21.             imgp = pygame.transform.flip(imgp, 1, 0)
  22.         elif x < 0:
  23.             d = 0
  24.             imgp = pygame.transform.flip(imgp, 1, 0)
  25.         if d == 0:
  26.             x += 2
  27.         else:
  28.             x -= 2
  29.     pygame.quit()
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement