In its current state, the game has four main files:
Enemies inherits from Player, Map_layout imports Enemies, and Game imports Map_layout.
The main job of this file is to hold all of the characteristics that could be useful to either the player or the other characters. This includes things such as lives, speed, gravity, attacking status, and more. But, the most important part about this class is that of collision detection. We wanted our game to react differently based on where the player (or other characters) are being hit on their body. Since PyGame's built-in collision detection isn't optimized for edge detection, we created our own. To sum it up, the general strategy we used was to have a set of points on the edge of the player's hit box. If certain combinations of those points are colliding with the map or other characters, we know that certain regions of the player/character are colliding with things. We can then use this information to make the game react in specific ways based on where things were hit.
This builds off of player.py by inheriting the class. This is needed mainly for the collision detection provided in player.py. Otherwise, this file helps serve as a centralized place where we can make new characters with slightly different or even new characteristics that the characteristics of the character defined in player.py. Things such as enemy type, number of lives, and movement mechanics are changed in this file to make the enemies more unpredictable.
This is the central place for map design for our game. In consists of a large amount of methods that help create certain things. Much of the file is composed of small methods that just create various objects and rectangles. These methods are used to create a variety of different blocks that can be used to make up the map as well as a variety of obstacles and enemies that can be put on the map to inhibit the player. These are used for modular map design so we don't need to individually calculate, by hand, the position and size of each block in the map. Each level's map is separated and draw when appropriate.
This is the file that brings all the assets together from the other files and runs the actual game. It has three main classes within it. The first is a Model class that brings all of game components (player, enemies, obstacles, map, etc) together and tracks all of the interactions between these objects. It has its own collision detection that tracks the basic collision detection from player.py as well as the collisions between the characters themselves. The next class is the PyGameWindowView. This draws all of the graphics that the user will see on screen. It uses the interactions in the Model class to draw specific aspects of the game. The last class is the PyGameKeyboardController class. This is used solely to interpret the user's inputs to the game and make the game react accordingly.