Lecture 9


PygameZero




  • Pygame

Pygame is a Python wrapper module for the SDL multimedia library. It contains python functions and classes that will allow you to use SDL’s support for playing cdroms, audio and video output, and keyboard, mouse and joystick input.

INSTALL PYGAME

Run this command in the terminal to install pygame

pip3 install pgzero


First Example





Hello PG!




Now, Try to show your name and change color,position,font size.

  • Shoot Duck Game!



Step 1

You should have duck picture for this step.







Step 2

Set random position after shoot duck.





Step 3

Function when you shooted.




  • Monkey Game!



Step 1

You should have monkey and banana picture for this step.





Step 2

Set random position of banana.



Step 3

Function motion of monkey and eat banana.





Step 4

Function count and show score.






Step 5

Function time up.







Step 6

change background!




Step 7

Set position monkey when take out of screen.

Bye :)

If you have any questions, please feel free to contact me.