Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.init()
- win = pygame.display.set_mode((500, 500))
- pygame.display.set_caption("Bouncy Ball")
- x = 210
- y = 400
- b_x = 250
- b_y = 100
- width = 100
- hight = 17
- speed = 16
- white = 255, 255, 255
- bold_drop = 17
- run = True
- while run:
- pygame.time.delay(40)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run = False
- keys = pygame.key.get_pressed()
- if keys[pygame.K_RIGHT]:
- x += speed
- if keys[pygame.K_LEFT]:
- x -= speed
- win.fill((0, 0, 0))
- rectancel = pygame.draw.rect(win, (white), (x, y, width, hight))
- pygame.display.update()
- ball = pygame.draw.circle(win, (white), (b_x, b_y), 7)
- pygame.display.update()
- b_y += bold_drop
- if ball.colliderect(rectancel):
- b_y -= bold_drop
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement