Contents
How to make your own destructible pixel terrain?
You can play the demo yourself, too. WASD to move, left click to shoot explosive bullets, right click to spray pixels. In our sidescrolling sandbox, the terrain will be the core mechanic of our game. Similar algorithms often have one image for the terrain’s texture, and another as a black and white mask to define which pixels are solid.
How to make a destructible landscape in POC?
The next step in the PoC (which I never got around to) was to use the SCC algorithm from the boost graph library to detect when a piece of the terrain had been severed (cut the top off a mountain). The severed terrain would still be destructible but now represented by a dynamic (non-static) Box2D body with the triangles attached as shapes.
How to make a destructible landscape in Box2D?
The only real hiccup was that the GLU tessellator can produce degenerate triangles which Box2D doesn’t like, so I had to filter those out by hand. The next step in the PoC (which I never got around to) was to use the SCC algorithm from the boost graph library to detect when a piece of the terrain had been severed (cut the top off a mountain).
How is the outline of a destructible landscape stored?
Use a vector graphics path representation for storing the outline of the destructible “land”. When a destruction event occurs (e.g., a grenade goes off), the blast area, represented as a circle, would be removed from the the land path via a boolean subtraction operation.
When to use mask approach to render terrain?
The mask approach would be more appropriate if you want to define each pixel’s properties, like how likely it’ll dislodge or how bouncy the pixel will be. To render the terrain, the sandbox draws the static pixels first, then the dynamic pixels with everything else on top.
How is the accuracy of a simulation broken?
The elapsedTime is the amount of time elapsed since the last update. The accuracy of any simulation can be entirely broken if the elapsedTime is too variable or too large.