The Art of Game Programming

This article is brought to you by Sams Publishing
publisher of Clayton Walnum’s  Sams Teach Yourself Game Programming with Visual Basic in 21 Days

When you first start studying game programming, you should examine why you might want to program games and why you might want to use Visual Basic to do it. In addition, you should take a brief look at the general process of creating a game. In this two part article, you’ll learn about the many areas of expertise you need to design and create a computer game. In short, you’ll learn the following:

  • How game programming can make you a better programmer.
  • Why Visual Basic is a good language for game programming.
  • The many skills needed to create a quality game.

Complex, But Not Too Complex

In my wild-and-wooly youth, I was a guitarist in a semiprofessional rock group. I’ll never forget the first time I walked into a recording studio to record a demo song with my band. In the control room was a huge mixing board with more buttons and switches than there are teeth in a great white shark. To the right was a patch bay from which snaked dozens of patch cords, each one connecting some vital piece of equipment to another. Lights blinked. Reels spun. Sound processing equipment with fancy names like phase shifter, digital delay, and multiband equalizer clicked on and off.

When I looked at all that complex machinery and considered that I was paying $60 an hour (the equivalent of about $150 an hour today) for the privilege of being there, I almost turned around and walked out the door. It seemed to me that just learning my way around this complicated studio would cost me my life savings. I could see myself being ejected from the premises, penniless, without having recorded even a note.

Luckily, I’d had some studio training, so I at least knew in a general way how a studio worked. Like everything else in life (well, almost everything), a recording studio isn’t really as complicated as it looks.

The same thing can be said about computer games. When you sit down at your computer and play the latest arcade hit or plunge into the newest state-of-the-art adventure game, you may be in awe of the talent and hard work that went into the glowing pixels that you see before your eyes. (And you should be.) But just like recording a song in a studio, writing games isn’t as difficult as you may think.

If you’ve had some programming experience, you already have much of the knowledge and skills that you need to program a computer game. You need only refine those skills with an eye toward games. Today you’ll get a quick look at some of the skills required to develop and write computer games.

The Hidden Benefits of Programming Games

You’re probably reading this article because you wanted to have a little fun with your computer. Consider if you had spent money to buy a book on programming games. When you were walking to the cash register with the book in hand, you might have felt a little guilty. After all, games aren’t serious computing, are they? You should be learning to write spreadsheet programs, databases, and word processors, right?

Let me tell you a quick story.

Way back in the dark ages of home computing (1981, to be exact), I got my first computer. It was an Atari 400, and like everything Atari made at that time, this powerful little computer was best known for its game-playing capabilities. After all, 1981 was the beginning of the golden age of video games, and Atari was the reigning king.

Unfortunately, after a few phenomenally successful years, video games spiraled into rapid decline and took many companies in the industry down with them. Computers became serious again. Although Atari managed to survive (barely), it would never be regarded as the designer and manufacturer of serious computers, thanks to its status as a game-computer maker. This is a shame, because the Atari 400/800’s successor, the Atari ST[md]along with the Macintosh and the Amiga[md]were way ahead of their time. Certainly, these products were light years more advanced than the “serious” IBM clones that were popular at that time.

The problem was that darn gaming image with which Atari had been saddled. Who wanted to use a game computer to manage a spreadsheet, balance a bank account, or track an investment portfolio? That would be kind of dumb, wouldn’t it?

Not really. The irony is that a computer that’s capable of playing sophisticated games is a computer that’s capable of just about anything. A good computer game taxes your computer to the maximum, including its capability to process data quickly, to generate graphics and animation, and to create realistic sound effects. Only a state-of-the-art computer can keep up with today’s high-powered games, such as flight simulators and 3D action games. In fact, there are few business applications in existence that require more computing power than a sophisticated computer game.

Similarly, a programmer who can write commercial-quality computer games can write just about any other type of software as well, especially considering today’s focus on graphics and sound in applications. You may have purchased this book to have a little fun with your computer, but before you’re done, you’ll learn valuable lessons in software design and programming[md]lessons that you can apply to many different kinds of software.
So, why program computer games? Mostly because it’s fun! But remember that your game-programming experience will help you with every other program that you ever write.

Why Use Visual Basic?

I could probably come up with dozens of reasons why you’d want to use Visual Basic to learn about game programming. I could also easily come up with reasons why you wouldn’t. The truth is that there are a lot of factors to consider when you’re choosing a language for game programming, not the least of which is the types of games you want to write. You may want to use Visual Basic to learn game programming for the following reasons:

  • It’s one of the easiest languages to learn.
  • It features a set of controls that make creating user interfaces quick and easy.
  • Visual Basic and its programming environment enable much faster application development than is possible with a language like C++.
  • It’s a powerful language that can handle all but the most complex applications.
  • Its drawing commands and tools enable you to create applications with professional-looking graphical displays.
  • It features controls and commands that manage bitmapped images with very little effort on your part.
  • Its extended implementation of the BASIC language allows not only user-definable data types, but also classes. This enables you to use some features of an object-oriented language.
  • It can call Windows API functions, which puts a huge library of advanced commands at your fingertips.

Types of Games Best Suited to Visual Basic

Let’s get something out of the way right now. If you want to write the next Quake or Might and Magic, forget Visual Basic. Such top-shelf games require programming power that’s very difficult, if not outright impossible, to get out of a language like Visual Basic (not to mention requiring many man-years of intensive labor). Most games in this class are written in C or C++ along with a healthy dose of assembly language–and even then, the programmers employ dozens of tricks to get the most out of the computer’s hardware. The intensive calculations and complex image handling needed in a real-time 3D game not only require a programmer with a degree in mathematics, but also a much faster language. What types of games, then, can you write with Visual Basic?

Games Using Straight Visual Basic

A game’s frame rate is the number of times the display is redrawn every second. Animation at frame rates much less than 30 FPS (frames per second) appears jerky and disorienting.

Although 3D games like Quake get a lot of attention, they represent only one genre in a marketplace packed with all types of games. Many other games, particularly those of the shareware variety, require much less programmer labor and processing power to create and run. By using straight Visual Basic without making calls to the Windows API or third-party libraries, you can write puzzle games, strategy games, card games, simple arcade games, and virtually any other type of game that doesn’t require intensive processing or fast frame rates. Many programmers also use VB to write prototypes for games. If those games turn out to be worthwhile ventures, the programmers will then develop the final games using C++ or some other language.

Visual Basic Games that Call the Windows API

As I mentioned previously, Visual Basic can call Windows API functions. Compared to Visual Basic’s intrinsic commands, in many cases Windows API functions exert extra power over a computer and allow your program to do things that cannot be duplicated with straight Visual Basic. For this reason, calls from Visual Basic to the Windows API may be just the trick to get a game running at its best. Although calls to the Windows API do not greatly extend the types of games you can write with Visual Basic, they can add pizzazz to what otherwise might be a lackluster game.

An application programming interface (API) is one or more libraries of functions that give a programmer access to a programming technology. For example, the Windows API is a set of libraries for programming Windows applications, whereas the Direct3D API is a set of libraries for writing graphically intensive applications.


This article presented some reasons for using Visual Basic to develop game. In the second part of this article I discuss the general process of creating a game.

About the Author

Clayton Walnum is an award winning author and game programmer who holds a degree in computer science and has written or co-authored more than 40 books covering everything from comptuer gaming to 3D graphics programming.

This article is brought to you by Sams Publishing
publisher of Sams Teach Yourself Game Programming with Visual Basic in 21 Days
) Copyright Sams Publishing, All Rights Reserved

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read