Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import pygame
- from time import sleep
- f, h = urllib.request.urlretrieve('https://yastatic.net/s3/lyceum/content/image/pygame/car2.png')
- img = open(f)
- if __name__ == '__main__':
- pygame.init()
- x, y = 0, 0
- size = width, height = 600, 95
- sc = pygame.display.set_mode(size)
- imgp = pygame.image.load(img)
- d = 0
- while True:
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, 0))
- sleep(0.01)
- pygame.display.update()
- if x > 450:
- d = 1
- imgp = pygame.transform.flip(imgp, 1, 0)
- elif x < 0:
- d = 0
- imgp = pygame.transform.flip(imgp, 1, 0)
- if d == 0:
- x += 2
- else:
- x -= 2
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement