Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from sys import exit
- pygame.init()
- display = pygame.display.set_mode((800, 600))
- tree_x = 300
- tree_y = 300
- tree_speed = 5
- running = True
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- keys = pygame.key.get_pressed()
- if keys[pygame.K_LEFT]:
- tree_x -= tree_speed
- if keys[pygame.K_RIGHT]:
- tree_x += tree_speed
- if keys[pygame.K_UP]:
- tree_y -= tree_speed
- if keys[pygame.K_DOWN]:
- tree_y += tree_speed
- pygame.draw.rect(display, (0, 128, 255), pygame.Rect(tree_x, tree_y, 30, 30))
- screen.fill((255, 255, 255))
- pygame.display.flip()
- pygame.quit()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement