Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from sys import exit
- from age import keys
- pygame.init()
- display = pygame.display.set_mode( (800, 600) )
- pygame.display.set_caption("MG1")
- x1 = 100
- y1 = 100
- x2 = 100
- y2 = 130
- x3 = 100
- y3 = 160
- x4 = 100
- y4 = 70
- x5 = 130
- y5 = 100
- x6 = 70
- y6 = 100
- speed_y = 0
- speed_x = 0
- FPS = 60
- clock = pygame.time.Clock()
- while True:
- speed_x = 0
- speed_y = 0
- keys = pygame.key.get_pressed()
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- exit()
- elif keys[pygame.K_s]:
- speed_y += 10
- elif keys[pygame.K_d]:
- speed_x += 10
- elif keys[pygame.K_a]:
- speed_x -= 10
- elif keys[pygame.K_w]:
- speed_y -= 10
- x1 += speed_x
- y1 += speed_y
- x2 += speed_x
- y2 += speed_y
- x3 += speed_x
- y3 += speed_y
- x4 += speed_x
- y4 += speed_y
- x5 += speed_x
- y5 += speed_y
- x6 += speed_x
- y6 += speed_y
- pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x1, y1, 30, 30))
- pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x2, y2, 30, 30))
- pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x3, y3, 30, 30))
- pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x4, y4, 30, 30))
- pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x5, y5, 30, 30))
- pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x6, y6, 30, 30))
- pygame.display.update()
- display.fill((0, 0, 0))
- clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement