Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys
- from pygame.locals import *
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- RED = (255, 0, 0)
- GREEN = (0, 255, 0)
- BLUE = (0, 0, 255)
- x = 200
- y = 200
- sx = 1
- sy = 1
- pygame.init()
- windowSurface = pygame.display.set_mode((600, 400), 0, 32)
- pygame.display.set_caption("Pallopeli")
- while True:
- pygame.draw.circle(windowSurface, BLACK, (x-sx, y-sy), 10)
- if y >= 400 or y <= 0:
- sy *= -1
- if x >= 600 or x <= 0:
- sx *= -1
- x += sx
- y += sy
- pygame.draw.circle(windowSurface, WHITE, (x, y), 10)
- pygame.display.update()
- while True:
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
Add Comment
Please, Sign In to add comment