Posts Tagged ‘level generation’

Transformagician Level Generation and Design

Posted by
Tuesday, May 3rd, 2016 12:42 am

"ANOTHER

I already touched upon the level generation in the Developer commentary video,
but that’s not enough info now is it! Here’s some more…

Tiles

One of the easiest ways to construct a virtual environment is to use tiles.
For me the decision to go with the technique was made even easier by already having an old tilemapping system laying around.
It was a bit rusty, but a few hours of mangling put it straight.

Sets

WallAndFloors

The tile graphics are as simple as possible. There’s a wall and there’s a floor.

I of course only implemented these assets as they were made by Ranquil. Pay special attention to the bump mapping!

Reading

The level is generated from an xml file. Here’s a little example:

<Ship type="TestMap">
 , , , , , , , , ,
 , . w . h . w . ,
 , . . . . . . . ,
 , . w . p . w . ,
 , . w w w w w . ,
 , . . . . . . . ,
 , . . . e . . . ,
 , . . . . . . . ,
 , , , , , , , , ,
 </Ship>

TestLevel

There are a few oddities right off the bat. The XML element is called a ship as that’s what the original project had, spaceships. The map is also flipped around as unity XYZ coordinates don’t quite match with the XY coordinates of the map file.

One nifty feature in the generator is spawning random rooms to specific positions on the map. The rooms themselves are defined in the same way as the maps.

<Room name="roomD" loot_a="0,1" enemy_a="2,6">
 w w w w . w w w w
 w . . . . . . . w
 w . w . w . w . .
 w . . . . . . . w
 . . w . o . w . .
 w . . . . . . . w
 w . w . w . w . .
 w . . . . . . . w
 w w w w . w w w w
 </Room>

And rooms areas are outlined with the characters R (room start position) and r (room limits).

 c c w c c c c c , , , , ,
 c c c w c R r r r r r r ,
 o c c c c r r r r r r r ,
 c c w c c r r r r r r r ,
 c c c w c r r r r r r r c
 c w c c c r r r r r r r c
 c c w c c r r r r r r r c
 c c c c c r r r r r r r c
 o c w c c r r r r r r r c
 c c c w c r r r r r r r c
 c c c c c c c c c c c c c
 , , , , , , c c c c c c c

(excerpt from a bigger map)

You can see the room randomization featured in the GIF.

Writing

Designing maps in black and white is kind of like programming in vanilla notepad, no syntax highlighting, no nothing. In other words clumsy and crude.

This issue can be resolved with conditional formatting in a spreadsheet (in this case Libre Office). Compare and contrast, the text file version:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
 , W w w w w w w , , , , , , , , , , , , , , , , , , , , , w c c c c c , , , ,
 , w p p . . . w , , , , , , , , , , , , , , , , , , , , , w c o c o c , , , ,
 , w p p w w . . c c c c c c c c c c c c c c c c c c c c c c c c c c c , , , ,
 , w . w R r r r r c c c c c c R r r r r r r r r c R r r r c w w , , c , , , ,
 , w . w r r r r r c , w c , c r r r r r r r r r c r r r r c , , , , c , , , ,
 , w . . r r r r r c , w c , c r r r r r r r r r c r r r r c , , , w c w , , ,
 , w w . r r r r r c , w c , c r r r r r r r r r c r r r r c , , , w c w , c ,
 , , , c r r r r r c c c c c c r r r r r r r r r c r r r r c , , , w c c c c ,
 , , , c r r r r r c c , w c c r r r r r r r r r c r r r r c , , , w c w , c ,
 , , , c r r r r r c o , w o c r r r r r r r r r c r r r r c , , , w c w , , ,
 , , , c r r r r r c c , w c c r r r r r r r r r c r r r r c , , , , c , , , ,
 w c c c c c c c c c c c c c c r r r r r r r r r c r r r r c , , , , c , , , ,
 , c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c , , , ,
 w c R r r r r r r r r r c c c c c R r r r r r r w c c R r r r r r c , , , , ,
 , c r r r r r r r r r r c c c c c r r r r r r r w c c r r r r r r c , , , , ,
 w c r r r r r r r r r r c c c c c r r r r r r r c c w r r r r r r c , , , , ,
 , c r r r r r r r r r r c c c c c r r r r r r r c c w r r r r r r c , , , , ,
 w c r r r r r r r r r r c c c c c r r r r r r r c c c r r r r r r c , , , , ,
 , c r r c c c c c c c c c c c w c r r r r r r r c w c r r r r r r c , , , , ,
 w c r r c w c w c w c w c c c w c c c c c c c c c w c r r r r r r c , , , , ,
 , , r r c c c c c c c c c c c w c R r r r r r r c w c r r r r r r c , , , , ,
 , , r r c w c w c w c w c c c c c r r r r r r r c c c r r r r r r c , , , , ,
 , , r r c o c o c o c o c w c c c r r r r r r r w c c r r r r r r c w w , , ,
 , , , , c c c c c c c c c c w c c r r r r r r r c c w r r r r r r c , w , , ,
 , , w w c c c c c c c c c c c c c r r r r r r r w c c r r r r r r c , w , , ,
 , , w w c w , , , , c c c w c c c c c c c c c c c c c c c c c c c c , w , , ,
 , , w w c w w , , , c c o w o c c R r r r r r r r c , , c c , , , c , w , , ,
 , , w w c w w w , , c w w o w w c r r r r r r r r c , , c c , , , c , w , , ,
 , , , , c , w w w , c c o w o c c r r r r r r r r c w c c c c w w c w w w w w
 , , , , c , , w w c c c c w c c c r r r r r r r r c w c o c c , , c , w , , w
 , , , , c , , , c c c c c c c c c r r r r r r r r c c c w o c c c c , w , , w
 , , , , c , , , c c R r r r r c c r r r r r r r r c c c o w c c c c , w , , w
 , , , , c , , , c c r r r r r c c r r r r r r r r c w c c o c , , c , w , , w
 , , , , c c c c c c r r r r r c c r r r r r r r r c w c c c c w w o w w w w w
 , , , , c w w w w c r r r r r c c c c c c c c c c c , , c c , , , w , w , , ,
 , , , , c c c c c c r r r r r c w c , w , , , w , c , , c c , , , , , w , , ,
 , , , , , , c w c c r r r r r c o c , , w , w , , c c c c c c c c c , w , , ,
 , , , , , , c w c c r r r r r c c c , , , w , , , c R r r r r r r c , w , , ,
 , , , , , , c w c c r r r r r c w c , , w , w , , c r r r r r r r c , w , , ,
 , , , , , , c w c c r r r r r c o c , w , , , w , c r r r r r r r c , w , , ,
 , , , , , , c w c c c c c c c c c c c c c c c c c c r r r r r r r c , w , , ,
 , , , , , , c c c c c c w c c c c c , , , , , c , c r r r r r r r c , w , , ,
 , , , , , , , , , , c c c w c R r r r r r r , c w c r r r r r r r c c c c c ,
 , , , , , , , , , w o c c c c r r r r r r r , c w c r r r r r r r c w w w c ,
 , , , , , , , , , , c c w c c r r r r r r r , c , c r r r r r r r c c c c c ,
 , , , , , , , , , , c c c w c r r r r r r r c c c c c c c c c c c c c c o w ,
 , , , , , , , , , w c w c c c r r r r r r r c c c c c c c c c c c c c c c c ,
 , , , , , , , , , , c c w c c r r r r r r r c w , , w c o c c w , c w w w c ,
 , , , , , , , , , , c c c c c r r r r r r r c w , , w c c c c w , c c c c c ,
 , , , , , , , , , w o c w c c r r r r r r r c c c c c c c o c w , , w c w , ,
 , , , , , , , , , , c c c w c r r r r r r r c w , , w c c c c w , , w c w , ,
 , , , , , , , , , , c c c c c c c c c c c c c w , , w c o c c w , , , c , , ,
 , , , , , , , , , , , , , , , c c c c c c c c w , , w c c c c w , , , c , , ,
 , , , , , , , , , , , , , , , c o c o c o c , , , , , c , , c , , w w c w w ,
 , , , , , , , , , , , , , , , , w , w , w , , , , , , c , , c , , w c c c w ,
 , , , , , , , , , , , , , , , , , , , , , , , , , , , c c c c c c c c h c , ,
 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , w c c c w ,
 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , w w , w w ,

With the conditionally formatted spreadsheet:

Spreadsheet

A thing a beauty! And here’s the map rendered in engine (flipped around this time, also no lighting)

Level2Full

Yet again there are a few issues. You need to jump though some hoops to get from the ODS spreadsheet file to the XML file. First the file is converted to the comma separated values format (CSV) and then the data is manually copied to the XML. Yeah, that last bit especially is not so great.

It is trivial to read the CSV file directly from Unity (something I didn’t know about way back then), so that’s what I’m going to do in the next project.

Conclusions

Tiles are a simple and powerful way to represent a level. Reading letter based map files is easy to code and fluid to create (with conditional formatting at least). Reusing systems that you’ve made before is a great boon to productivity. Take advantage of previous work as often as possible.

And, of course, you can play Transformagician right here.

LD31 – Update 2: A New Generation

Posted by
Saturday, December 6th, 2014 10:21 am

2

As claimed in the previous update, my level gen code didn’t take much longer to complete.  I can now generate an interconnected system of rooms and hallways, separated by doors.  Making doors something that can be opened/closed will not be difficult once I actually get a character in and moving around.  That’s the next goal:  Dude and move.  Then doors and vision.  Then we work on stats, enemies, combat, inventories… so much left to do!  But at least I’m already the furthest I’ve ever made it on a rouge-like, so I’ve already succeeded at something great!

It’s getting there

Posted by
Sunday, December 15th, 2013 9:24 pm

After adding the parts to flip the tiles it was still kind of crazy so I had to go through and clean things up, make some things work how I didn’t intend and make it so there could be more empty space. It’s much better, but there is still a decent amount that needs to get done.

The right side I have to deal with and I’m thinking I may need for it to fix up certain areas automatically because as is, the logic can’t fix all the problems due to it not knowing what the next piece will be.  I may have it look ahead one space to choose the best piece, but that’s still a lot of work.

YouOnlyGetOne3

Level Generator

Posted by
Sunday, December 15th, 2013 4:32 pm

So I started the compo very late and I won’t be able to finish in time, but might for the jam.

Anyway since I haven’t made a post yet, I should explain.

My idea was to make a climing game where you only get one life and chance, meaning if you die you can’t play the game again, you know like real life, basically because I’m an ass (unless you delete the hidden file, then you can play again, but you lose your score).  Well I decided on 2D and for it to be pixel art, haven’t done either before, main mechanics were pretty easy to manage, but the biggest thing has been making the level randomly generate, which I’ve also never done before.  Let’s just say it’s taken a while to do that and partway through I realized I needed another piece.  The art is actually pretty easy, though I’m not much of an artist, used the program Pyxel.

I’ve been working in Unity, as that’s what I’m used to, pretty easy for 2D games from what I can tell, was easiest to program my own controller for it instead of using anything built in.

As you can see in the image, it looks like crap, that’s because I haven’t added anything to flip the pieces, which is used to determine what to place, based on what’s below and to the left and if the one to the left is facing left or right.  Once I get that, a lot of issues should clear up.  I’ll also need to shrink the character, and make art for that.

YouOnlyGetOne2

[cache: storing page]