Original topic can be found here:
Destructible Terrain
originally posted by Alezunde
We've all seen them, from the classics Scorched Earth, Dig Dug, and Sopwith, to modern marvels like Worms and Red Faction. Destructible Terrain (DT)! This is not something so readily available to the GM user. DTs break down the clean and memory-neat concepts of tiled backgrounds and holds every pixel or polygon accountable for it's own life on the screen.
The nature of destructible terrains makes it a complicated feature to overcome. Giving every element of the image it's own presence tends to bog down processors and require enormous amounts of memory... that is... if you try and do it the most obvious way. First attempts at GM DTs tend to try to place an instance per pixel or sometimes, per small square sprite (basically a large pixel.) But these systems fail because suddenly you have hundreds of thousands of objects running collision routines to build up terrain in the smallest of playable areas.
Obviously, DTs need a more clever approach to function properly in GM. The tools that have been used to further GMs DT technology include parameterization of objects (subdividing big objects into little ones when needed), ds_grids and other datastructures (to manage pixel perfect collision and hole-punching routines with the set_disk functions), and surfaces (to easily edit the on screen information.) Some GMCers have even stepped into the 3D realm using data structures to manage the vertices of ground planes.
DTs require more engineering than simply blasting away the background. Consideration has to be given as to how objects will collide with the transforming terrain. One might also want the ability to paint terrain back into the environment, or convert dynamic objects into destructible terrain. Will suspended terrain cascade to the nearest floor? How can you tunnel in 3D? Some of the concepts for destructible terrain may be beyond the capacity for GM's runner. But that doesn't mean we can't try.
Here are some online references to programming Destructible Terrains:
YoYoGames Wiki Page on DTs
Existing Examples:
- KXDTE Kaietnap's impressive extension shows just how possible Destructible Terrains can be in GM. Though Kaietnap hasn't released the source, this is a good place for GMCers to go who don't have the time or ability to create a system from scratch.
- Post 2 on this page By Icuurd
- Post 3 on this page By Indecom
- (This list will grow with posting of new examples - or old ones with merit. If you have an example, submit it!)
Because this topic is starting anew, some older concepts will be welcomed back into the fray. So don't be afraid to post. Seeing some games in the past several months that have done some clever things to simulate destructible terrain has really expanded the expectations for such a system!
PS - for those who followed my examples in the old thread, I have lost a lot of the original source files, but I plan on recreating the project with the things I've since learned in the near future. The Destructible Terrain examples were some of my favorite experiments! The source for my latest released example is still available in my signature.













