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: taskpy paste the starter code to begin critter.py or similarly named file. See below and designtxt 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
Coding Notes
Prework
The game window will be x
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 catchkill 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 to
drawposition where the image should be drawn on the screen. All critters should start in the middle of the screen.
centerposition the center of the image to help detect catchkill
radius determined by the minimum dimension of the image. To help determine catchkill
Methods
draw
Draw the image on the screen in the appropriate spot
movecritter
Again, you can name this something different if your theme is different.
Update the position of the critter
checkbounce
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: getwidth and getheight 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.
didgetlocation
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 collidepointpos 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
taskpy
Design: You will do the design for the game loop.
It may be easiest to break it into three sections.
Get InputEvents
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 didget 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 critterslist
Create list of critters by calling makecritterslist Details below.
Player movement is controlled by the mouse.
Call pygame.mouse.setvisibleFalse 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 catchkill
Check to see if the tool hit a critter
Call the didget 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 that is the position of the top left corner of the can. The nozzle for the spray might be around 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 gameround 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
