Skip to content

Latest commit

 

History

History

Day-5

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

##PyGame Animation

Grab the starter file animation.py and copy it into a new Python window.

Download the image beach_ball.png and save it in the same location as your Python file (you can right click the image and select "save image as").

Try running it!

If you receive the error:

Traceback (most recent call last):
  File "C:/Python25/pygame tester.py", line 16, in <module>
    my_ball = pygame.image.load('beach_ball.png')
error: Couldn't open beach_ball.png

Then your image file was not saved in the correct location!

Read through the file to see what it is doing.

####Challenge #1 Can you make the beach ball appear lower on the screen?

####Challenge #2 Can you make the beach ball go twice as fast?

####Challenge #3 Can you switch the beach ball's direction?

####Challenge #4 Can you add a second image to the animation? Download a small image from the internet (look, here is one or do a Google image search) and save it in the same location as your Python file. What new variables do you need to create?

####Challenge #5 Can you make one of the images travel in both the x and y direction and bounce off all four walls?

####Challenge #6 Can you make the other image travel left and right, bouncing off the walls and doubling in speed each bounce? Increasing the speed by 10% might work better. You also might need to give it a max speed!