Improving an existing little arcade game
Around 2-3 years ago, I developed a simple arcade game with one of my characters from my short films. I did it just for fun, to try making such thing and to learn something new in programming. This course offers me the opportunity to fix/refactor code of this game and improve it.
Basic info about this project:
- Used libraries include
pygame
,keyboard
, file prober fromtkinter
, ... - The game features a simple GUI, level loading, character/camera movement, passive obstacles and score collecting
- The whole game is scaled based on resolution (stretching)
- Ability to easily make playable content in the game; features a working Level Editor, images pasted into asset folders can be immediately used for designing levels
- Uses OOP for the core functionality/rendering, inheritance from classes in
pygame
The game features a playable character, who must collect score points (pieces of data) and overcome obstacles to reach the end. The basic functionality is done, the playable content only consists of testing levels.
How it works
- It consists of three parts (files)
- "main.py"/"LevelEditor.py" - the main loop, a big
while
cycle which controls the inputs, game mechanics and blits the screen. Utilizes the other two modules listed below. - "var.py" - handles loading the assets for the game, stores important variables, is more like a database for all important assets in the game.
- "funkce.py" - an important module for the game, contains objects for levels, obstacles, scores, UI, ... ,the OOP part of the game.
- "main.py"/"LevelEditor.py" - the main loop, a big
The main loop is unique for each application. When I was making the Level Editor, I had the other modules already prepared in such a way that I didn't have to code anything from scratch, I just assembled the pieces together (which I really like about OOP), so it didn't take much time to do.
So it has OOP, but... what else? What is the goal here?
The goals
... is to improve the game with the knowledge from this course.
- storing the level info
- right now it uses something that can't even be called a mockup of
.json
file structure to read/save level data. The implementation is entirely custom-made and may be hard to expand if I wanted to add more features. - I'm proposing the usage of
pandas
for creating a table/structure to store levels more conveniently
- right now it uses something that can't even be called a mockup of
- looking into opportunities for optimization
- the game uses either native Python or
pygame
data structures. Perhaps some computations can be made more faster usingnumpy
- the game uses either native Python or
- monitoring the games performance with
matplotlib
- currently the game contains a little debug menu for showing some information that can be revealed by adding
showDebug
line in the settings.txt file. It could be improved by adding an exportable graphic report of performance
- currently the game contains a little debug menu for showing some information that can be revealed by adding
- improving the documentation of code
- the game has a few comments here and there, but no proper documentation. It is easy to forget how it works after all these years.
The current state of this project can be found in the link below. If anyone wants to run this, I recommend activating the Python venv first. Additionally, if you're using Linux, you may have to give it root access (careful) to make the keyboard module work and install Pulseaudio
https://drive.google.com/file/d/1QsTlTz-IdfpbagyPMeh3cIIWfIb2SSBG/view?usp=sharing
.