Question
For this assignment, we'll be working with PyGame. Before you start, you will have to install PyGame. Each question involves modifying the code in Answer
For this assignment, we'll be working with PyGame. Before you start, you will have to install PyGame.
Each question involves modifying the code in Answer each question in a file called qXX.py where XX is the question number. To make your life easier, start with this zip file.
Unless specified otherwise, these questions are all independent so, for example, your program for Question 3 should not have a background that changes color every second (Question 2).
Submit all your python code and any other files (images, sounds, or fonts) needed to run your code.
Assignment Questions
If you have trouble understanding what any of these questions is asking, see the sample video that is (or will shortly be) posted at the end of this assignment.
The PyGame documentation will be helpful and so will the example that we did in class.
- Modify the sample code so that the background color is red.
- Modify the sample code so that the background color transitions through the sequence black, red, green, blue, orange, yellow, brown. The background color should change once per second (every 30 frames). You can use this list of colors to figure out the RGB color codes.
- Use Google's advanced image search to find a reasonably-sized image that is free to reuse and that includes transparency. Modify the sample code so that it draws your image centered in the middle of the screen.
- Modify the sample code so that your image sits in the middle of the screen and rotates at a rate of 2 revolutions per second 1 revolution every 2 seconds. (See pygame.transform.rotate() documentation)
- Use Google's advanced image search to find a reasonably-sized image of a ball that is free to reuse and that includes transparency. Modify the sample code so that your ball slides back and forth across the bottom of the screen. It should take 2 seconds for the ball to go from the left side to the right.
- Improve your animation for question 5 so that the ball rotates, accurately, as if it were rolling back and forth.
- Modify your animation for question 6 so that the ball travels counterclockwise around the edge of the screen
- Using the system default font, with a size of 200 100, draw your name centered in the middle of the screen. (See pygame.font.Sysfont() and Font.render()).
- Download a free TrueType font (this is a file that ends in .ttf) from somewhere like this site. Using this font, draw your name centered at the top of onthe screen. (See Font() for information on how to create a font from a file.)
- Download four .wav sound files from some site like this. Make an application that plays a different one of these four sounds when the user presses one of the 'a', 's', 'd', or 'f' keys.
- Make a simple application in which the image of a ball repeatedly moves to some location on-screen that the user has clicked. Each click should play a sound. Each time the ball reaches it's target play a different sound.
- (Bonus question.) Write a simulation that simulates balls being fired from the bottom center of the screen at some angle that ranges between 70 and 110 degrees. Some force like Earth's Gravity should act on these balls so that they eventually fall down. Each time the user hits the space bar a new ball is fired.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started