Spacefight – A game from the ground up – part 1

falseAbout 20 years ago, I had a desire to create my own game. At that time I had some basic programming skills, but I was still very much a beginner. With no clue about how to make a game. In the mid 90’s few people had access to Internet, and my group of friends weren’t into programming, which meant that it was very hard to get the “know-how” on how to program games. So my ambition of making games soon faded away.

For quite a while it’s been on my wish-list to start a new “pet project” on my spare time. I realized that during these years as a web developer, I have acquired a much deeper understanding in software development. So why shouldn’t I try to make a simple game, and give the old dream a push?
I made a short list of some guidelines for the project:

  • The game should be completed. Including sound/music, graphics and game play.
  • The game should not be big.
  • The game should be portable to many platforms so be sure to select the right libraries.
  • The game should be built pretty much from the ground up.
  • The game should be programmed in C++.
  • The game should have a good structure in order to grow.

The game should be completed

It is important for me to be able to finish this project. So instead of just doing a prototype with missing sound or graphics, I would really like to make a playable game. This also means that I’ll spend some time bettering my poor skills in graphics and music, in order to deliver something complete.

The game should not be big

I have experienced it so many times before; Grand ideas and meter long feature list. Which usually ends up that the project feel enormous and I’ll get discouraged.

I figure, if I make a simple space ship game and get it working, I’ll then have something to build upon. And hopefully get some reusable code that I can apply to future projects. I came to think about an old PC game called Galactix. This was the first game I played on my 386sx in the early 90’s and it’s a fairly simple game that could be used as some inspiration.

The game should be portable to other platforms

It’s important to have builds that run on the most popular devices today. I do all my programming under Linux. But I would also like the game to run on Windows and Mac. People today play games under so many platforms like: Android, IOS, Windows, XBox, PS3/4 and other devices/consoles. It’s therefore important to select the right game libraries which offer portability between different platforms.

I’ve gone for libSDL for my game. Mostly because I’ve known the SDL project for a long time. SDL came to life in the late 90’s, when Loki software ported different Window games to Linux and Macintosh. I know that version 2.0 of SDL is out. But I went with version 1.2, since I believe its the most supported version among different platforms. With SDL, I get routines for 2D graphics, sound and input support, that I need for my game.

The game should be build from the ground and up

The whole point of making this project should be that I get something back from it. Apart from getting a game done, I would also like to gain knowledge about how to make sprite animations, make things move on the screen, game-loops and structure the game.

The game should be programmed in C++ (Why?)

C++ is one of the first languages I got to know and I would like to re-connect to this familiarity. C++ is still the most popular language for software- and game development due to its speed and dynamic memory allocation. It is a hard typed language, where you always need to know what kind structure or variables you are using. Otherwise it won’t compile or just plainly crash. It will be a different experience in comparison to my regular daily programming languages (Python, Javascript and PHP) which are loosely typed .

C++ can also be a big pain in the ass. Since you need to keep on top of what memory you’ve allocating and what memory you freeing. If you accidentally free memory you have in use, your  program will die (see: segfault). And you need to free the memory, otherwise your program will be a memory eating beast.

The whole point by choosing C++ as a language, is that it will give you these hard learned lessons, when it comes to memory management. It will hopefully teach me some valuable points when it comes to allocate and free memory in a program.

 The game should have a good structure

This will be my first attempt on creating a game structure. So I expect it won’t be perfect, but the code structure should contain important parts, that I will be able to use again. For instance loading images, creating animations, loading and playing sound & music. It should also be possible to add more content and functionality further down the road. Without messing up the code too much.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.