This repository is a submission for "Raccoons Virtual Hackathon". Hackathon Link
A very simple 2D game where the character jumps and dodges the viruses, infected people and bats. Further the game ends once you reach your home. Difficulty of the game can be changed by changing the virusvelocity variable.
What can Video Games do in our lives? Well, a typical answer will be they are a source of fun and enjoyment. Well, that's true, but a new generation of gaming isn't just hanging at the peak of pleasure or entertainment, but today they're also getting active in the field of learning.
Especially with a touch of AR and VR, these games can be useful in all types of learning, whether it be to train a surgeon for medical emergencies or to visualize the "Elephant Toothpaste Reaction" without getting worried about spillage and equipment.
I have always been curious about learning new things, whether it be related to stem or something else (though, I am always inclined towards STEM). Game Dev is a booming field and seems to have a promising future if correctly used.
Though I am well versed with other Development (App-Dev/ Web-Dev/ Designing) and Instrumentation Tech (IoT/ Robotics etc.) but Game-Dev was always something which I wanted to learn, and that's what turned me to try it here for the first time!
Vs What I did in JS using p5.js
- It allows you to Roam around the city, which is apparently static (unless you add your custom background :-P) and look for the virus-infected people or viruses escape them till you reach your home, which is at the end of your city.
- In this adventure, you will see different types of viruses that will try to infect you! You're a raccoon, and you're on a mission to sanitize the city without getting infected.
- To escape from the viruses, you have to ensure that you don't come in contact with them at any cost! Also, you need to keep a distance from those who are already infected.
- Unless you're not sanitizer protected, any incoming virus can infect you. If you catch a sanitizer (which always happens), you will be able to blow it three times before it ends, and then you have to protect yourself against them.
- For all the land viruses, you need to jump and skip them. On the other hand, for all the air viruses, you need to bend down and let them pass away.
- With your speed, it takes a fixed amount of time to reach the end of the city where your sanitization process is over, and you could safely keep yourself locked unless the pandemic ends!
I started building it with pygame tutorials available on Youtube. This entire game is solely built with pygame library. The characters (in the form of png images) are prepared in Microsoft PowerPoint.
The Raccoon moving GIF was broken to extract frames by using this python code. So yeah, that's pretty much of it! I built it using Python, Pygame, PowerPoint, PIL, and lots of love!
All the Commits along with the messages linked to their respective changes have been added in github. These changes are:
- Create Readme.md
- Add License File
- Second Commit Adding Characters
- Added Walking Functionality
- Added Viruses and other graphical interfaces and also added collision Detection
- Final Modifications
If I look back, there were lots of things I struggled with such as:
- Getting Started with Pygame
- Differentiating Between Surfaces and Geometries (Rectangle:- Trust me, my first raccoon was just a box 😛)
- Collision Detection Algorithm: (All Credit Goes to DrawFunction in my Script, which helped me visualize the errors I was making and modify it to the best kind of collision detection)
if RoadX>=xInit and RoadX<=xInit+CharacterSize: if (yTop<=RoadY+HeightVirus and yTop>=RoadY) or (yTop+CharacterSize<=RoadY+HeightVirus and yTop+CharacterSize>=RoadY):
- Jumping Algorithm: This one was the trickiest of all. Since it follows a parabolic trajectory, I struggled to create that realistic jump effect. And aborting the jump if I want to crouch.
def jump(y,jumpLim,flag): if jumpLim==-jumpMag: jumpLim=jumpMag y=yInit flag=0 else: y-=jumpLim*abs(jumpLim)*jumpGrowth jumpLim-=1 #print(f"Jump values:{jumpLim}") return(y,jumpLim,flag)
- Identifying the right Entity and it's effect.
- Resetting all effects time to time.
The very basics of Pygame, movement simulation, velocity, blit and draw.rect functions. Time clocks, ticks, updating windows etc. In short, Basics of a 2D Game development using Pygame.
And this will produce a flow chart:
I have created this project mainly because of three reasons:
-
Getting Exposure of Game Development This project has pretty much helped me to take my first step towards Game development, slowly I would try to dive deeper and do more customizations and learn more.
-
For the Beginners and Developers For the Beginners and Developers who want to learn PyGame, I am planning on converting this project into Video Tutorial Series. This will not just be there for them to get started with PyGame but also to use this project as the base template to do the modifications in their own project.
Pretty much every 2D game needs jump and axis movements and so if this could be any helpful to them, I would be extremely happy. I would love to see amazing games built in reference to this small project.
-
For the Kids and Babies to Develop their Minds to Generate Awareness about Cleanness and Sanetization This game could led to a positive awareness among the mind of kids and create a good image of importance of sanitation and hygene in maintaining their health, I am not sure how nicely it will work, but expect it to have some positive impact.
In order to play this game, You must ensure that you have pygame installed as your python library. In case you don't, just enter this command:
python3 -m pip install pygame
If your default python is called out by py then you may try this command:
py -m pip install pygame
Or if your default python is called out by python then you may try this:
python -m pip install pygame
Note that if your pip is associated with environment variables then you may directly go with:
pip install pygame
Once the installation is finish, either you can run it from python IDLE shell or you can manually write this script in your CMD:
python3 PlayGame.py --diff Medium
For easy or hard mode:
python3 PlayGame.py --diff Easy python3 PlayGame.py --diff Hard
Kindly make sure your first letter of mode-type remains capital as the choices are case sensetive.