Skip to content

Commit ac2d13a

Browse files
committed
Version two balls bouncing but flicker error ball2
1 parent caa67a2 commit ac2d13a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bouncing_ball/bounceball.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
pygame.init()
44

55
size = width, height = 620, 540
6-
speed1 = [1.5, 1.5]
6+
speed1 = [2, 2]
77
speed2 = [1, 1]
88
black = 0, 0, 0
99

1010
screen = pygame.display.set_mode(size)
11+
pygame.display.set_caption("Bouncing Beach Balls")
1112

1213
img1 = pygame.image.load("ball1.png")
1314
img2 = pygame.image.load("ball2.png")
@@ -28,13 +29,17 @@
2829
speed1[0] = -speed1[0]
2930
if ballrect1.top < 0 or ballrect1.bottom > height:
3031
speed1[1] = -speed1[1]
32+
3133
if ballrect2.left < 0 or ballrect2.right > width:
3234
speed2[0] = -speed2[0]
3335
if ballrect2.top < 0 or ballrect2.bottom > height:
3436
speed2[1] = -speed2[1]
3537

3638
screen.fill(black)
3739

38-
screen.blit(ball1, ballrect1, ball2, ballrect2)
40+
screen.blit(ball1, ballrect1)
41+
pygame.display.flip()
42+
43+
screen.blit(ball2, ballrect2)
44+
pygame.display.flip()
3945

40-
pygame.display.flip()

0 commit comments

Comments
 (0)