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 = 0
- y1 = 0
- 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
- pygame.draw.rect(display, (0, 128, 255), pygame.Rect(x1, y1, 30, 30))
- pygame.display.update()
- display.fill((0, 0, 0))
- clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement