Programming Q&A

Topics discussed here: Web Applications - In particular: HTML, PHP and MySQL apps Windows GUI - I have over fifteen years experience writing MS Windows Apps in C++. Got a problem? Give me a crack at it. Introduction to Game Programming

Wednesday, December 06, 2006

Gaming Basics

I'd like to propose a little project here for anyone that wants to follow along and/or contribute. The result will be some kind of arcade style game for Microsoft Windows. We will write the project in C++. I have a Microsoft Visual C++ compiler, but any C++ compiler should do as the goal is to use only Win32's rather than relying on MFC or some other non-standard library.

The basic steps any game needs to perform during the game cycle is as follows:

1) Paint the background to an offscreen buffer.

2) Paint the "sprites" to to the same offscreen buffer.

3) Display the offscreen buffer by telling the video hardware to swap buffers OR blit the buffer to video memory all at once.

4) Process and respond to user input.

5) Detect and respond to any collisions.

6) Update statistics such as scores, lives or time left.

7) Possibly update the sound buffer according to the events of this cycle.

8) Repeat the cycle until game end.

If you've read just a little about game programming, you've probably heard the term "sprite". The term is older than my 25 year experience with game programming. A sprite is basically an object that you move around the screen such as ships, people, bullets... You differentiate sprites from the display background because the player typically does not interact with the background, only other sprites. Therefore, when you look for "collisions" (sprites overlapping or hitting other sprites), you ignore the background.

Years ago I wrote a C++ sprite class for some of the games I wrote thereafter. It is an interesting and entertaining exercise. It allows you to abstract the display of the sprite so that you can adapt the sprite class to different target platforms (DOS, Windows, XWindows, Apple whatever...).

I am open to comments. If you would like to write your first game or contribute based on your experience, join in and let's go. I will publish source and you can too. BTW, I am no artist, so any help you can provide I would much appreciate.

Tuesday, December 05, 2006

About The Editor

I worked about 15 years as a software engineer before I realized the income potential of the World Wide Web a few years ago. Several years before that, we began a family project of building a hunting and fishing web site, mainly to promote my father's game ranch. We probably spent upwards of $2000 on wages and artwork for our site ( We ended up with about 1000 hunting outfitters and fishing guides that we listed at no charge. Their listings included contact information, the name of their business, a short description of services and a web site link if available. The result was nothing spectacular but we had a site with a lot of content. We began charging for these links a little while later when we noticed that more and more people were finding our site through search engine searches. Most of the people entered our site, not through our home page, but through one of the customer links. They would search for things like 'bison hunting' or 'salmon in alaska' and end up at our page. Many of our clients were surprised to find that our link pages ranked higher than their web sites, even though they might be searching for their own particular business (ie searching for their business name).

Charging for listings had marginal success as there were many companies competing for the same clients.

A year later, we discovered Google Adwords. Since we basically had about 20 pages (several of them with server side scripts that displayed the 2000+ customer records and directories thereof), it was basically a four hour task to add Adwords to every page. We were impressed with the immediate results. The income was not enough to quit my day job, but there were times that the program made our ends meet when our other business was not cutting it. Probably more than anything, however, was the thought of receiving income without "working" for it. I know, we did a lot of work upfront to get the site going, but Adwords is more like profitting from an investment than working for an hourly wage.

So let this blog begin. I would love to answer questions about programming. My personal interest in the field is web site development (especially with PHP and MySQL), GUI's, the Fox Toolkit and game development concepts. My original interest in computers was sparked when I bought an Atari 2600 sometime last century. When I heard that you could develop games with a computer, I had to get me one o'dem! I bought a TI-99/4A back in 1981, followed by a TI Professional Computer (doomed to fail because it was trying to compete with IBM PC's, without being compatible). After watching TI abandon the PC race, I bought an Atari 1040 ST. The ST was a step above the TI for games, but not much in the way of computing. Finally, I joined the clone wars by buying a Gateway 2000 computer (386-33Mhz) with enough RAM to run DOS and Windows 3.1 for the lowly price of $4000. No, it was not a laptop and not Internet ready. Since then I've basically stayed behind the price curve by buying six month or older technology. Currently my home PC is a laptop and probably three year old technology. I've found that if I can run Microsoft Visual C++ 6.0 and get my email, I'm content.

I published a small space shooter game complete with scrolling backgrounds, my own sequencer for MIDI file playback, wav sounds back in 1992 while working at Tandy (Radio Shack R&D). That's not too impressive unless you know about the hardware (80286 - 10Mhz). It was a challenge balancing frames/second, music and scroll speed. The main purpose for developing the software was to test our console sytem (the VIS), which died due to market pricing of $700. People pay that much now for a PS3, but the VIS was no PS3.

I'm looking forward to answering programming questions, group developing games or discussing our lives in Honduras at the children's home.