Python Game Development Through the Lens of a Data Analyst
Gabriel Margonato
Data Analyst | AWS Certified | ETL | Python | SQL | PowerBI | Tableau | Power Platform | Power Apps
Introduction?
With the legal matters out of the way, let me share my journey into the fascinating world of game development. My passion for games began early on, and it was this passion that led me to pursue a bachelor’s degree in computer science. I enjoyed playing games, but I often felt that the games I loved were missing something. This drove me to tweak and implement my own changes in the open-sourced games I played, sparking my interest in game development.
Initially, my focus was on game design, but a pivotal moment came during my second to last year at university. I participated in a Data Hackathon (Datathon) that shifted my career trajectory towards Data Science. Despite this shift, my enthusiasm for games and programming never waned. I continued to work on small projects, but there was a significant challenge: my intensive focus on Python for data analytics caused me to lose touch with object-oriented programming.
Earlier this year, I decided it was time to revisit my game development skills. Although it is commonly believed that Python is not the best language for game development, I chose to use it because of my extensive experience with it over the past eight years. This decision proved to be fruitful. In this article, I will share the story of how I combined my data science expertise with my love for game development using Python.
Video showcase: https://vimeo.com/973212296
Why Python?
Despite Python not being among the top programming languages for game development, often criticized for being slower than C# or C++, I decided to pursue my hobby project with it, as previously mentioned, driven by my familiarity and confidence with the language.
During my initial research, I discovered PyGame, a key framework for game development in Python. A framework is a platform that provides a foundation of pre-written code and tools to simplify the development process. PyGame, released over 20 years ago, offers a plethora of documentation and tutorials online, including resources on YouTube, GitHub, and StackOverflow. Equipped with a Mac M1 and after completing a few test projects, I became convinced that Python was a viable choice for starting my game development journey.
Designing the Game
The idea for my game was rooted in simplicity, yet I wanted it to be engaging and challenging. I aimed to create an adventure game where players could control a character and explore a dynamic world. However, given that this was my first major project, I decided to avoid implementing complex physics like gravity, which could complicate the code.
While exploring various genres, I discovered beat 'em ups—a game style where players fight their way through hordes of weaker enemies, eventually facing a powerful boss. This genre was perfect for my needs. It offered the right balance of simplicity and excitement, allowing me to focus on game mechanics without getting bogged down by overly complex systems.
With the concept in place, I moved on to coding the game mechanics. The core of the game involved simple player movement and combat. Using Python and PyGame, I implemented straightforward controls that allowed the player to move the character up and down, go forward and retreat, and engage in combat with waves of enemies at specific points. I also added health packs. The simplicity of these mechanics ensured that the game was easy to pick up and play, while still being enjoyable.
The combat system was designed to be simple and intuitive: players could attack and block. Each character could perform a combo of three attacks that play in sequence if they are not hit. Attacks can be either punches or kicks. To help the player deal with larger groups of enemies, I also implemented the ability to shoot and use a special area-of-effect (AOE) attack.
By blocking and punching at the same time, players could fire a character-specific ability: Captain America throws his shield, which can be caught back mid-air or retrieved later from the floor. Spider-Man uses his web shooters to "freeze" a small enemy for a few seconds, while Hulk throws a giant rock removed from the ground. By blocking and kicking, players could use the AOE ability: Cap hits the ground with his shield (only if he has it, otherwise, nothing happens). Spider-Man goes up his web and catches thieves just like flies, pulling them out of combat for good. And Hulk? He smashes.
领英推荐
Game Assets
One of the most challenging aspects of game development is creating the game assets. As this project is a learning experience and a hobby, I decided to use resources from other games that I truly admire. As mentioned earlier, I do not own any of the intellectual property for the characters and images used, and I don't plan on commercializing this project. Above all, I respect and admire the talented artists who created these assets.
For my project, I drew inspiration and assets from two iconic games. The streets, buildings, and other scenario elements came from "Teenage Mutant Ninja Turtles: Shredder's Revenge." This game's detailed and vibrant environments perfectly suited the urban setting I envisioned for my own game. For character sprites and animations, I turned to "Marvel vs. Capcom" (both the original and its sequel). This classic arcade game, which I loved playing as a kid, provided a wealth of dynamic and expressive characters.
Using these assets allowed me to quickly develop my game and focus on learning the intricacies of game development. And while borrowing these assets was instrumental in my learning process, I recognize the importance of creating original content. In the future, if I decide to develop other games, I plan to invest more time in studying and creating my own game assets. This will allow me to fully own my projects and showcase my unique artistic vision.
Next Steps
While it would be easy to focus on adding new characters, move sets, and jumping mechanics, one aspect that could significantly increase replayability* is procedural level generation. *[Replayability: the quality in a video game, music recording, etc. of being suitable for or worth playing more than once. Synonym: replay value.]
Currently, the game features only one level: the streets of New York City. My initial plan included three levels: the streets of New York, the sewers/subway tunnels, and Central Park. However, due to time constraints and other priorities, I couldn't complete these additional levels. Some early assets and sketches for these levels can be found on the project's GitHub page (https://github.com/gmargonato/PyGame_Avengers_BeatEm_Up).
To minimize the workload required to create new challenges for players, procedural generation of the map is an effective solution. As described earlier, the map is composed of tiles representing different elements: the skies, foreground (city elements like cars, trees, poles), midground (streets), and background (buildings). The procedural generation method would randomly select a new set of these elements and dynamically add them to the edge of screen – this would ensure that every new game presents a fresh and different cityscape for players to explore. Additionally, a randomizer for enemy quantities, health packs, and boss encounters could further enhance the gameplay experience.
The key consideration for implementing this feature is ensuring that the background and midground elements match seamlessly. For example, if a building with a garage door is selected, the algorithm should pick a corresponding street tile, such as a lowered sidewalk with tire marks, to ensure visual coherence.
?
?
As illustrated in the example above, the algorithm must recognize the selected building and choose a matching street element to maintain consistency in the world’s environment.
?
Conclusion
This project was more than just a coding exercise; it was a personal journey to prove to myself that I could re-learn a skill I once had — object-oriented programming — and reignite my passion for game development. Throughout this process, I was reminded of the joy and creativity that game development brings, and I discovered that it's never too late to learn something new or pick up where you left off, no matter the gap.
My hope is that by sharing my story, I can inspire others to pursue their passions, whether it's learning a new skill or rediscovering an old one.
The path may be challenging, but the rewards are immensely satisfying. Remember, it's never too late to embark on a new journey and achieve your goals.
IT Audit & Information Security | PCI-DSS | SOx | Governance, Risk and Compliance
8 个月That's amazing, I'm proud of you! ??
SW Delivery Manager
8 个月I am very proud of you. Your journey certainly inspires others to re-think their own decisions and possibly change their mind about next goals. You Rock !!!
Preven??o a Fraudes | estratégia | meios de pagamento | modelagem de fraude
8 个月Tu é fera, Gabriel Margonato !
Playstation | Expert in Game Design
8 个月Keep it up Bro
My "Scrum Master Certification Guide" is now on Amazon! || 250K+ Followers on Twitter || Mojo Maven || PSM || PSD || CSPO
8 个月Awesome work!