Home of Ebyan Alvarez-Buylla

World Generation Breakdown

World Generation Breakdown

A large part of Dance of Death v0.6.136 was the addition of world generation. Although the world is little more than a large island at the moment, the results are rather satisfying, even considering that the current method of generating terrain is purely based on elevation. After experimenting with a number of techniques, I settled on this simple formula: 1) Generate Fractal Perlin Noise, 2) Multiply noise by a radial gradient, and 3) Apply terrain and water line. Here is the breakdown:

WeightedLetter Name Generator

WeightedLetter Name Generator

This name generator takes a seed of similar sounding names (or any words), and generates a new set of names based on the likelihood that one letter follows another in the original set. It picks the first and last letter, generates the letters in between, best-matches the second-to-last letter, and runs post-generation triple-letter and Damerau–Levenshtein checks to ensure uniformity with the seed.

Procedural Space Invaders

Procedural Space Invaders

These simple procedurally-generated Space Invaders-style sprites were directly inspired by Jared Tarbell’s classic Invader Fractal. The concept is straightforward: start with a grid of a set width and height (3×5 works well), and mirror on the x all tiles except for the center one. You can see it in action here and grab the source code from GitHub.

Procedural Radial Flowers

Procedural Radial Flowers

At my wife’s request I bring you a direct spin off of the Procedural Space Invaders, only this time rotated along a center axis to create procedural radial spirals, or “flowers”. You can see it in action here and grab the source code from GitHub.

Cocos2d iPhone Repeating Sprite

Cocos2d iPhone Repeating Sprite

Since Cocos2d iPhone’s OpenGL is only capable of repeating textures that have dimensions which are a power of two, I’ve put together a quick-and-dirty algorithm to tile arbitrarily-sized sprites to arbitrary sizes. TiledSprite takes a source sprite with a texture from a file or a subtexture from an atlas, and clips and/or tiles to fit the requested width and height. The source code is available on GitHub as a Gist, just copy-paste it, download it, or clone the repo and grab the .h and .m for use in your project.