# How can I place nice-looking tile-based cliffs automatically?

Legend of Zelda: A Link to the Past had some pretty nice cliffs. I'd like to create something similar, but am having trouble figuring out how to place them.

Anyways, I have a bunch of tiles like in the above image. How can I simplify how they are placed in the game world? I currently have a 50x50 grid and a painter class in Java that tells the system where to place the tile: Painter.fill(this, 15, 30, 13, 50, Terrain.EMPTY) would fill X-15 and Y-30 with a set of EMPTY tiles (basic ground tiles) 13x50 tiles wide. I can also apply 'for' loops to paint the entire map with a type of tile, or tell it to only make a row X-tiles long, like this:

for (int i=0; i < LENGTH; i++) {
if (map[i] == Terrain.EMPTY && map[i+50] == Terrain.WATER){
map[i] = Terrain.CLIFF_S_BOTTOM;
map[i-50] = Terrain.CLIFF_S_MID;
map[i-100] = Terrain.CLIFF_S_TOP;
}
}


Is there a simpler way I could be telling my code to place lots tiles in a particular formation quickly?

EDIT: I just learned about the concept of bitmasking. I think this will solve most of my problems, but I'm still open to other ways of solving the problem.

Enums keep appearing as a possible alternative to the bitmask solution. Are they viable for this application?

• Are you looking for something like gamedevelopment.tutsplus.com/tutorials/… ? – Josh Oct 26 '16 at 20:31
• Hah...little sheepish here. I had never heard of bitmasking before you mentioned it. – user5352515 Oct 26 '16 at 20:35
• I skimmed the article. It looks like I can use bitmasking to solve a lot of the problems I've been running into. – user5352515 Oct 26 '16 at 20:38
• It should be noted that if you go with bitmasking, you're limited to 64 permutations. – Krythic Oct 26 '16 at 23:37
• The power of bitmasking comes into play when you need a tile that's passible, swimmable, and a cliff. – Krythic Oct 26 '16 at 23:44