Game Code

This category contains 6 posts

Artificial Life Simulator (in VB6)

Here you have it: the largest, most complex programming project now available on tannerhelland.com. Originally a final project for a university bioinformatics course, this artificial life simulator has now been completely retooled as a full-blown lesson in evolution and population genetics. As with most artificial life simulators, a set of simple artificial creatures compete for limited resources. Each creature has a strand of pseudo-DNA that determines three basic attributes: size, speed, and range (how far it can see)…

Mathematically Generated Fire – REVISED

Because the first draft of this project has become so popular, I’ve gone ahead and built a new and MUCH faster version. Updates include: DIB sections for flame drawing, look-up tables, optimized randomization, and custom flame coloring. On my old 1.6ghz laptop this version runs over 4x faster than version 1.0. Enjoy!

How to Use Math to Create Fire

Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs a fast, cool fire effect at some point in his/her career. In this example, I’ve opted for a straightforward and easy-to-understand method for generating real-time flames. No pre-built images or palettes are used, making the code quite small (only 11kb, including a demo exe) and very easy to reuse. Coloring and flame generation is done using only math and a little cleverness…

Basic Game Physics (Velocity and Acceleration)

This site spends a lot of time focusing on the graphical side of game programming, but what about the underlying math that drives game engines? After an evening of being inspired by the marvelous Havok physics engine, I decided to bust out some old arcade game code and use it to demo classical mechanical physics. The demo has a pretty simple premise – use the arrow keys to fly a spaceship (taken from the classic game Raptor) in all 4 directions and use spacebar to fire two “lasers.” Also, for any VB-haters out there, it’s worth noting that if the demo’s frame rate limitation box is unchecked, the code will easily run 500+ FPS on any modern machine. Still think VB6 isn’t a viable choice for game programming?

Color Shifting – 200% More Graphics for Free! (VB6)

Color shifting is a very fast, very simple effect that can greatly simplify the work of game artists. (Above is a demonstration using a classic StarCraft Siege Tank.) It is also extremely simple to implement – all we do is shift the red, green, and blue values of each pixel to the right or left. This allows us to generate two additional color variations on a source image without any extra work. (Read the rest of the article for details and sample code…)

Because gray-toned values have RGB values that are identical (or nearly identical), color shifting doesn’t change the appearance of gray pixels. This is pretty clear on the siege tanks above, as the color shifting merely adjusted the subtle hues of the gray regions…

Game Map Editor (Tile-Based) in VB6

Who doesn’t love a classic tile-based game? VB6 seems to be especially popular for writing tile games, so I’ve put together a simple tile-based map editor for any aspiring game creators out there. The demo is pretty self-explanatory – click on the tile bar at the top (with either the left or right mouse button) to select a tile, then click on the large center window to draw that tile onto the map. Scrolling and zoom are fully implemented, as are saving and loading map files. I’ve also written the engine using both StretchBlt and PaintPicture, and you can use the combo box on the left to specify a painting method.