Python: Space Shooter
I started this as a project for my Digital Content, Design, and Usability class, where we were instructed to research any topic of our choosing and create a blog about it. I decided to learn how to program a game in Python, a language I was unfamiliar with at the time, using a set of libraries called Pygame. I recently returned to it to develop it further. While something similar may be more easily possible in GameMaker, this was written entirely in code, without the convenience of a drag-and-drop game design environment or premade physics functions. While the game itself is not quite done, I feel it was a good learning experience for object oriented game programming. I included comments in the source code to describe what is going on.
Some highlights:
-
I decided to split the updates per second from the frames per second, as indicated by the upper right hand corner, using a library called GameClock. Without this clock, the UPS would equal the FPS. This clock then calls the draw and update functions accordingly.
-
At the base of the physics, I created a Vector object. Every time a GameObject updates, it calculates the next position using a velocity vector based on the acceleration, drag, and a maximum speed.
-
Precise pixel collision is performed by gathering a list of GameObjects and placing a mask on each to compare with the player’s mask.
-
I wrapped the screen by detecting when the player intersects with each corner or side and creating duplicated accordingly.
Controls: Use the mouse in the menu, and the "WASD" keys in the game screen. I decided to give the menu screen different controls just to see how to program mouse inputs. The controls may change as I further develop the game.
**Run using spaceshooter.exe under the Executable folder**