Linux Format

Create a 2D shooter


Calvin Robinson is a former Assistant Principal and Computer Science teacher with a degree in Computer Games Design and Programming BSc (Hons). CalvinRobinson.

We’re going to have a go at creating our own 2D shooter. We’ll be using Python for this tutorial, so make sure it’s installed and updated, along with the PyGame module. pip3 install pygame should get everything set up. We’ll need some image and sound resource files which can be downloaded from the LXF archives website, along with a complete copy of the source code for reference.

Launch Python IDLE and select File > New File to create a new document in the Script window. It’s important to type code in the Script window, rather than Shell, because it’s then editable and saveable.

We’re going to start off by importing PyGame, since this module provides a lot of game mechanics that we’ll want to tap into. We’ll also initialise our game world ( init ) and set the screen resolution:

Now that we have a working game environment, we’ll need to start adding things to it. Let’s begin with our player

You're reading a preview, sign up to read more.

More from Linux Format

Linux Format1 min read
Linux Format
Editor Neil Mohr LateLateLate editor Jonni Bidwell Art editor Efrain Hernandez-Mendoza Operations editor Cliff Hope Group editor in chief Graham Barlow Senior art editor Jo Gulliver Editorial contributors Mike Bedford, Neil Bothwick, Tam Hanna, Matth
Linux Format1 min readComputers
Custom Crosshair
Modern FPS enable you to customise your gun’s crosshairs. This wasn’t the case with the original shooters. If we want to update our game to provide that level of functionality, we’ll have to edit our and look our for the code below: Here, w
Linux Format1 min read
Sculpt A Cup In Blender
In Object mode, add a cylinder to the scene. Then change to Edit mode. Choose Face Select selection mode and select the top face of the mesh. Now press X to see the Delete menu and select Faces to delete the top. This gives you a bin-shaped object. R