thinBASIC TBGL Website

by Petr Schreiber 

AirDogs 1942

by Michael Hartlef, November 2007

AirDogs 1942 in game shot First I want to thank Eros Olmi and Roberto Bianchi for creating thinBasic and Petr Schreiber for creating the TBGL module. You guys do a great job!

If you develop games or applications with thinBasic, then you might know my little game called AirDogs 1942. It is a little 2 player WW2 dogfighting game between two fighter planes.

In this article I want to tell you a little about how this game came together, from the idea to the actual implementation. I hope it will be worth reading. So first comes first, or how did I got the idea for AirDogs 1942?

The motivation that drove AirDogs development

Well, I'm the developer of TBDI, a DirectInput module for thinBasic. With this module you can use joysticks, steering wheels and gamepads in thinBasic, including their Force-Feedback abilities. In the beginning it supported only the first connected controller but of course, this wasn't enough.

The implementation for multiple controllers was build into the module pretty fast. I think I needed 2 days for it. That proofed that a good source base helps a lot when you have to touch some code after while again :)

The first version of the TBDI module had just a simple sample script that printed only the controller values on the screen. Nothing fancy. But for version 2 I wanted to do something different. Something playable, a little game should be created.

Which game should I develop?

While playing against my son on the Playstation 2, I got the idea about a 2 player game. Good, I can use two controllers then, but which game I asked myself? Again, history kicked into my mind and I remembered countless hours playing with my buddies on one of the 80's game consoles.

I think we had them all (at least the ones available here in Germany). The ATARI 2600, the Colleco, the Schneider, etc.! And then I remembered a game cartridge from my old Atari2600. It was about TANK and PLANE fighting. Talking about the planes, you saw them in a top view, with some clouds drifting over the screen. The purpose of this game was to shoot your opponent of the sky. Nothing fancy but fun as hell. At least we had it!

So I decided to recreate something similar. As I'm very interested in the WW1 and WW2 air wars, my decision was to take WW2 as a theme. The game should be about 2 planes fighting each other in the sky. The name was found very fast too, AIR DOG fighting…. So AirDogs 1942 was a good choice I think.

How long will it take?

Creating a whole game takes time you might say. That's right and I was eager to publish my finished module for thinBasic. So I set myself a timeframe of 2-3 weeks to develop a playable game. 2-3 weeks after daily job, attending to family life and so on. So you could say that I had between 30-40 hours to get the job done.

Not much, isn't it? If you think about it, besides the whole coding you need the media too. Images, sound effects, music tunes. If I was going to create everything myself, then it would take me 2-3 weeks for this alone, better 6-8. Thinking about this, the next decision was to take stuff from the internet that was already available.

Collecting the media files from the internet

So I started search for aircraft sounds. A good site and where I got them finally from was a page about mods for Flight simulator and Combat Simulator.

They had engine sounds from some of the major and most famous fighter planes, the Spitfire and the FW190. To cover the sounds effects for the guns, I came across a free sound effect library.

I'm sure I will use this library in the future too, as it covers a wide range of areas.

The explosion sounds I took from a different thinBasic game called TopDown3D. They don't really fit the impact of a bullet into a plane but that doesn't matter. Inside this mash of sound (engines, shots, explosion, music) you can't hear them good anyway! :)

For the title music I decided to go with MIDI files as they are small and if well composed can also sound good. I found this page that has some famous war tunes and I picked one of them.

I think it fits the theme of the glory days of flying heroes perfectly.

Let me see something

Ok, I had now all the sounds I needed. Next were images and graphic effects.

I needed a title screen image, buttons and a background for the menu. Then I needed sprites for the planes, the clouds and the shots.

Last but not least I needed images to reassemble smoke and an explosion.

The planes and shot particle images were found fast, as I remembered the free sprite lib from Ari Feldman.

He has a sprite set for a 1945 plane fight game in it, and I decided to take two of these planes for my game. They look cartoony and so I had to take this into count when looking for cloud sprites and the particle effects.

Airplane of player 1

Airplane of player 2

I decided then that I would assemble the title screen from real photos of that time. I found a page about famous war airplanes and their pilots.

I took several pictures and assembled them with Photoshop 6 into a nice looking title screen. Since the image had to be faded in and out, I had to make sure that the sizes of width and height was both a power of 2 (32,64,128,256,etc.) That makes sure that TBGL can display them fast enough for a nice fading effect.

Here is the result:

Title screen

The clouds and the smoke particle images were created in Photoshop too. I used a sharp edged brush with slight colour variations. Inside TBGL, the blur at the edges anyway so they look smooth then. But also because of the sharp edge, I could colour key the background and make it transparent. Another reason to create them like that was the cartoony look of the planes. This way, they fit each other.


Smoke from hit airplane

Initially TBGL had no color keying functionality but Petr Schreiber developed this within one day after I asked. A perfect example of how the development of thinBasic and its modules work. Just go to the forum and ask, you might be surprised how fast it will be implemented.

The menu buttons were created in Photoshop also. Photoshop has a nice metal plate texture and that was used for the background plate and the buttons. The buttons got some split edges that look like a bullet went through them. I like them, but there I forgot to watch the size.

Later a forum member noticed a huge frame drop when the menu was displayed. I found out that it was because the size of the button texture wasn't a power of 2. After correcting the size, the menu was displayed very fast.

Button from menu

Start coding

Ok, having all the media together, I decided to start coding. I didn't create a design manual this time as the code was not going to be that big, but I decided right at the beginning, that my subroutines should be flexible, means that they would have some parameters to make them reusable for another game.

To me, coding is also building a personal library of functions. Just like a toolbox. And at the next job you decided which tool will fit the task and then you use it. You can transfer this method from tools to source code too. The internet is full of code. Most of the time it is from another programming language but once you had learned the other language a little, you can convert stuff easily.

Basic structure of the game

First of all, this is my personal opinion and based on my own experience. I'm 100% sure that everybody would come up with a different solution. So please be nice with me if I made up silly stuff.

Ok, almost every casual game could have this basic code structure:

  1. Load media, setup variables
  2. Show title/Intro
  3. Game loop
    • Display menu
    • Play 2 player game
    • Play 1 player game
    • Change settings
    • Exit game loop
  4. Show end sequence
  5. Unload media

Each of these parts is then split again, like this:

  • Load media
    • Load graphics
    • Load music
    • Load sound effects
  • Show title/Intro
    • Blend in title screens
    • Start playing title song
    • Blend out title screens
    • Stop music

And so on. I don't want to turn this article into a tutorial so I leave the rest for your imagination. You can also study the source code of AirDogs 1942 which is available here:

AirDogs 1942

I tried to create reusable functions, means I tried not to put fix values into them. Of course, when you see that the resolution of the game is fix, then you know that I didn't complete followed this rule. :)

Some things were also left out of the game, like the 1 player mode or the ending sequence. I simply reached the deadline I set myself. Plus not everything is fine tuned. There are some bugs left inside but one day I will try to fix them. Or maybe you?


Again, I reused some code, but from another thinBasic game called TopDown3D. Basically setup routines and initial game loops, so I could display something very fast. Nothing is more motivating than seeing your creation on the screen. At least for me it is like that. And as long as you credit your sources, then I think it is not a bad thing doing it this way. It's also a good way of learning when you try to understand other people's code and change it the way you need it.

Some more ideas for AirDogs 1942

Several things could improve the game but were left out because of the deadline I had set myself. For an example, a 1 player mode would enhance it big time. Also that a pilot could choose different airplanes. The planes could have different speed, turning and shot rate, damage, etc etc...

Some powerups could add to the gameplay too. They could speed up shot rate, give you more health. Or thunder clouds, that release lightning bolts towards a plane if it comes to close. Of course they would damage the plane. Or a 2 player mode over the internet? How cool would that be! How about a computer controlled wingman? Or something more simple, a hi-score list.

You see, there are so many things that could still be done with it. So go ahead and try your hands on it. When I find time I will try myself.

In game shot


Writing this game in this short time frame has showed and taught me a lot. A lot about thinBasic and a lot about myself. Mainly that I can tackle such a project and finish it.

It is very important to set yourself a goal and that you stick to it. Finish what you wanted to do at first and THEN try to enhance it. If you always change your direction then you will never reach your goal. And try to start small if you never created a game or application.

ThinBasic and its modules are very powerful and will give you strong toolset for all kinds of games. It's up to you to take advantage of this.