|
The terrain in the original Scortched Earth was implemented using a basic "sand" engine. There's a 1-bit "mask" bitmap that defines the terrain, and you deform it by just cutting holes in the mask. If the mask is altered, run passes of the sand algorithm until the terrain has settled. The sand algorithm is simple. For each pixel in the mask, if there's empty space immediately below, shift the pixel down one row. Else, if there's empty space to the lower-left or lower-right, shift there instead. (If both are empty, use a random number to break the tie.) It's like a cellular automata process. With these basic rules, the sand will tend to form pyramid-shaped piles. You can extend the proces with more rules (sideways motion) to cause them to flatten more. Watch for bias issues when doing this: you may need to cycle from bottom to top, and alternate left-to-right then right-to-left as you process all the pixels. Not doing this may cause your sand to settle with a left or right bias, or get spaced out as it falls. Count the number of pixels that shift with each update, and when you fall below a threshhold (1 is probably the right choice given how fast computers can do this today), you're done.
|
# ¿ Mar 2, 2008 02:24 |
|
|
# ¿ May 8, 2024 02:47 |