Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.init()
- #CHARACTER VALUES
- charWidthX = 50
- charHeightY = 60
- charSpeed = 5
- charPosX = 50
- charPosY = 50
- #COLOUR VALUES
- black = 0, 0, 0
- white = 255, 255, 255
- red = 255, 0, 0
- green = 0, 255, 0
- blue = 0, 0, 255
- #SCREEN VALUES
- screen = pygame.display.set_mode([1000, 650])
- screen.fill(blue)
- pygame.display.update()
- pygame.display.set_caption("Test Game")
- run = True
- while run:
- pygame.time.delay(100)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run = False
- keys = pygame.key.get_pressed()
- if keys[pygame.K_LEFT] and charPosX >= 5:
- charPosX -= charSpeed
- charPosX -= charSpeed
- if keys[pygame.K_RIGHT] and charPosX <= 940:
- charPosX += charSpeed
- charPosX += charSpeed
- if keys[pygame.K_UP] and charPosY >= 5:
- charPosY -= charSpeed
- charPosY -= charSpeed
- if keys[pygame.K_DOWN] and charPosY <= 580:
- charPosY += charSpeed
- charPosY += charSpeed
- screen.fill(blue)
- pygame.draw.rect(screen, (white), (charPosX, charPosY, charWidthX, charHeightY))
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement