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…
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?
Real-time transparency has become so commonplace in modern games and PC applications that it’s almost taken for granted. However, the specific formula that performs this now-ubiquitous effect is worth understanding.
Transparency is simply a weighted average between the color values of two pixels. As an example, consider the following two colors:
Pure red, or RGB(255, 0, 0)
Pure [...]
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…
This is one of my all-time favorite image effects – a simulated blacklight that looks GREAT on any image with people in it. I invented this algorithm myself, and the provided code will allow you to test the effect in real-time on any image below 2MB. (The sample image is Squall from FF8 – the greatest RPG ever made, btw…)
This is the first of its kind in VB: accurate, real-time image level adjustment. Image levels provide better control over luminance than strict brightness/contrast methods, but not quite as much control as a well-built Curves Dialog. Adjusting an image using input/output/midtone levels is useful for brightening or darkening an image without losing detail at either end of the luminance spectrum. I’ve included simple histogram drawing code (as the screenshot shows) so you can see the effect that adjusting levels has on an image’s histogram. The code is well-commented and fast – please post comments and/or requests for future VB graphics projects.
By request, here is the first of its kind in VB: a fast, accurate, real-time image curves dialog. (This should be familiar to any PhotoShop users out there :) Curves is similar in theory both “Image Levels” post and standard gamma correction, but it provides a much more powerful interface for adjusting the luminance of an image. This project provides results very similar to Photoshop’s, and it allows the creation of more spline knots (32 instead of 16). The code is well-commented and very fast – please post comments, requests for future Photoshop-related code, and many heaps of praise (as this was a complicated routine to sort out…)!
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.
This program demonstrates how to create a smooth color gradient between any two colors on any size of form. While gradients are often used for visual effects (especially since the advent of modern OSes), perhaps the most useful aspect of this project is the algorithm used to draw a gradient. Many other algorithms (like image [...]
Resampling involves using interpolation algorithms when resizing an image to minimize negative impact on image quality. For example, when you resize a 50×50 image to 500×500 the image looks horrible – it looks like a bunch of giant squares. Resampling reduces that blockiness by interpolating pixels, so the image looks rounded even after it’s resampled. [...]