Question: You will submit three files: task 1 . py ( paste the starter code to begin ) , critter.py ( or similarly named file. See

You will submit three files: task1.py (paste the starter code to begin), critter.py (or similarly named file. See below), and design1.txt. The design will only be the game loop.
Game Play
The player attempts to catch good critters and kill bad ones. You may do any other theme that still works with the overall technical requirements. You could crush rubies with a red hammer and emeralds with a green hammer or something like that.
The player uses the mouse to play. They hit the mouse button to use their current tool. If they miss then nothing happens. If they hit the appropriate type of critter, then the critter is removed and the tool toggles to the other tool. If they hit the wrong critter the game ends. They can hit a key to start a new game.
If the player successfully clears all critters the round is over. A win message is displayed along with the time the round took. The user can hit a key to start a new round which increases the number of starting critters by 10.
Coding Notes
Pre-work
The game window will be 1280x720.
Collect images for: background, two player tools, good critter, and bad critter. Use all images as appropriate.
Scale the images to something reasonable.
Collect sounds for: background music, tool used (one sound for each tool), successful catch/kill (can be the same sound or you can use different sounds), game over, round won.
critter.py
Create a Critter class. Note: You can call this something else if your theme is different. gem.py might be good for my example given above.
Include the following as parameters in __init__
screen - The critter object will draw itself on the screen
type - This indicates the type of critter the object is (good or bad). It will be used to determine if the critter was caught or killed. You can choose what data type to use. An integer might be a good choice.
image - The image for the critter
Other instance data - You can decide what you need. Here are suggestions
move - a list [x, y] which indicates how the critter should move. Should be random values from -15 to 15.
draw_position - where the image should be drawn on the screen. All critters should start in the middle of the screen.
center_position - the center of the image to help detect catch/kill
radius - determined by the minimum dimension of the image. To help determine catch/kill
Methods
draw()
Draw the image on the screen in the appropriate spot
move_critter()
Again, you can name this something different if your theme is different.
Update the position of the critter
check_bounce()
This might be a little different than other ways we've bounced things off walls
The critter will detect if it hit a wall or not and will adjust its move list appropriately
Hint: You can get the dimensions of the screen from the screen parameter in the initializer: get_width() and get_height() will do it.
Note: The entire image should always be on the screen. When the edge of the image hits a side, it should bounce.
did_get(location)
The parameter is the [x, y] location of the mouse (or what you consider to be the main point of your tool)
Hint: Rect objects have a .collidepoint(pos) method that takes an [x, y] position and returns true if that position is inside of the rectangle
Returns the critter type if it was hit
Returns another value if it was not hit
task1.py
Design: You will do the design for the game loop.
It may be easiest to break it into three sections.
Get Input/Events
Update State
Update Display
In the design you can just state the functions and methods will be called where appropriate.
Ex. Then in the loop call did_get() on each one of the critters and ...
Paste in the starter code. Modify as necessary (Window size and title)
Set up all game components as you see fit not specified here.
Keep track of critters in a list called critters_list
Create list of critters by calling make_critters_list(). Details below.
Player movement is controlled by the mouse.
Call pygame.mouse.set_visible(False) to make the mouse not visible
Use the position of the mouse to determine where to show the current tool
The mouse button indicates the action to try to catch/kill.
Check to see if the tool hit a critter
Call the did_get() method on the critter with the tool's location.
Some point on your tool should be the meaningful hit point. For example, the tip of the chopsticks or the tip of the canister makes sense for my example. That is the point that should be used to see if it's in the critter's space. For example, for the canister if I draw at (100,200), that is the position of the top left corner of the can. The nozzle for the spray might be around (125,200) which is the location I should use to check to see if I hit a critter.
Play sounds at appropriate time
Ongoing background music (does not play during the game/round over screen)
Tool used
Tool success (can be the same or different sounds for each critter)
Round over

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!