The aim of this project is to create a game using pygame module.
-
If standalone script, short description of script explaining what it achieves. The player controls a small squirrel that must hop around the screen eating smaller squirrels and avoiding larger squirrels. Each time the player’s squirrel eats a squirrel that is smaller than it, it grows larger. If the player’s squirrel gets hit by a larger squirrel larger than it, it loses a life point.
-
List out the libraries imported.
- random
- pygame
- sys
- time
- math
Download the squirrel python code file.
Install the pygame module - pip install pygame
Double click the code and enjoy the game.
- Importing the required modules
- Describing the Data Structures
- The main() Function
- The pygame.transform.flip() Function
- A More Detailed Game State than Usual
- The Usual Text Creation Code
- The “Active Area” set-up
- Keeping Track of the Location of Things in the Game World
- Starting Off with Some Grass
- The Game Loop and Checking to Disable Invulnerability
- Moving the Enemy Squirrels
- Removing the Far Away Grass and Squirrel Objects
- When Deleting Items in a List, Iterate Over the List in Reverse
- Adding New Grass and Squirrel Objects
- Camera Slack, and Moving the Camera View
- Drawing the Background, Grass, Squirrels, and Health Meter
- The Event Handling Loop
- Moving the Player, and Accounting for Bounce
- Collision Detection- Eat or Be Eaten
- The Game Over Screen and Winning
- Drawing a Graphical Health Meter
- The Same Old terminate() Function
- The Mathematics of the Sine Function
- Backwards Compatibility with Python Version 2
- The getRandomVelocity() Function
- Finding a Place to Add New Squirrels and Grass
- Creating Enemy Squirrel Data Structures
- Flipping the Squirrel Image
- Creating Grass Data Structures
- Checking if Outside the Active Area
Output.mp4
Rammya Dharshini K
None