Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import pygame
- f, h = urllib.request.urlretrieve('https://yastatic.net/s3/lyceum/content/image/pygame/creature.png')
- img = open(f)
- if __name__ == '__main__':
- pygame.init()
- x, y = 0, 0
- size = width, height = 800, 600
- sc = pygame.display.set_mode(size)
- imgp = pygame.image.load(img).convert()
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, y))
- pygame.display.update()
- while True:
- for i in pygame.event.get():
- if i.type == pygame.QUIT:
- exit(0)
- elif i.type == pygame.KEYDOWN:
- if i.key == pygame.K_RIGHT:
- x += 10
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, y))
- pygame.display.update()
- elif i.key == pygame.K_LEFT:
- x -= 10
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, y))
- pygame.display.update()
- elif i.key == pygame.K_UP:
- y -= 10
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, y))
- pygame.display.update()
- elif i.key == pygame.K_DOWN:
- y += 10
- sc.fill((255, 255, 255))
- sc.blit(imgp, (x, y))
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement