Space Commander is set in space (no surprise there!) where your starship is flying through an infinite 2D world. Enemy ships spawn all around you and then start to attack your ship in waves. Your objective is to destroy all the enemy ships in each wave to progress to the next level.
As you progress your ship is upgraded, but you’ll also face more powerful enemies. Not only are they harder to destroy, but they have more powerful weapons such as guided missiles and fireballs.
The game world is much larger than your screen so you’ve got a radar display to show you where your enemies are. Use this to line up your attacks before you can even see the hostile ships.
As you shoot enemy ships they will loose power and slow down. You’ll see injured ships trailing debris as they move. As you are hit your ship health indicator in the top left of the screen will deplete. If it gets to zero your ship will explode. If you loose health your ship will slowly repair itself and replenish your health.
Space Commander is heavily influenced by, or maybe copied from, one of my favourite BBC Microcomputer games from the 1980’s. Have a look here to play the original Beeb version of Starship Command.
All the original gameplay is there but I’ve added homing missiles and fireballs and done away with the escape pod system to jump levels.
This series of tutorials covers the main coding challenges for the game. I’ll cover each challenge in a separate video so you can have a go at building up the game yourself and get the help you need when you want it.
I’m not planning to teach you the very basics of coding. Please check out my beginner courses for Space Invaders and Asteroids if you’ve never coded before. In those tutorials I’ll take you through from your first line of code to building full, working arcade games using TIC80, a complete games development system ideal for novice coders. After that you’ll be ready for this challenge. But even if you’re new to coding do watch the videos to see what’s possible with a little bit of knowledge.
This game uses vector graphics to allow game objects to be rotated freely. Normal bitmap sprites can only be rotated by 90 degrees increments in TIC80 so we’d need to create lots of drawings of our ships to get a smooth looking animation.
Drawing the game elements as lines (vectors) allows us to smoothly rotate and scale.
The game takes place in an infinite 2D space. All of the game objects live and move in this space. Our code needs to model this behaviour and the physical constraints within it. How fast can ships accelerate and decelerate? How fast can they turn? What happens when they collide?
On top of this modelling we also need to draw the objects on our screen. The game keeps the player ship focussed in the centre of the screen, pointing upwards. As the player ship moves and rotates in the game world we need to render this on the screen by rotating and moving it around the player ship. This gives the player the sensation that their ship is flying through space even though we’re drawing it as space flying around the ship.
Maybe coding AI is a bit of an overstatement, but we do need the enemy to attack in a sensible manner. For this we’ll need to develop a set of rules that govern their movement and attack tactics.
In essence each enemy ship will operate individually. Once they spawn they will attack the player ship, fire their bullets and then retreat. After this they simply repeat the process until they are destroyed.
Our code needs to work out how to control this set of rules and how to apply them to make the ships appear to be intelligent.
Part of the AI aspect of the game involves the enemy ships being able to track the player ship. This code can then be reused to build guided missiles.
Guided missiles again need to be modelled in the software to have thrust, maximum turn rates and rocket boost durations to make them behave a real physical objects.
There are always other aspects to developing the game but those will be covered as we go through the coding.
This series is designed to allow you to have a go at the coding yourself. In each tutorial I’ll walk you through the concepts and algorithms needed to design the code. It’s then up to you to write your own or follow me through my solution as I explain how I implemented the software.
Make sure you subscribe to my YouTube channel to keep up to date with all the tutorial releases, and above all, have fun coding!