Sunday, June 12, 2011

New Block Type

Hello everyone, I have a game update to share with you. As of tonight, I have a rudimentary way of random inserting a new block type into the game world. Right now, I'm only using dirt and coal (new) blocks. I'm pretty excited about this newest addition to the game, as it will allow me to begin work on other things such as the player's inventory.

My method for putting coal blocks in the game is pretty simple at this point. First, I loop through all the blocks in the map, looking for the first non-null blocks (meaning that this block is theoretically the ground level for this particular column). I then loop through the current column and have a set of 'if-then-else' conditions that check if the column block in question is at a certain depth. Based on the depth there is a chance that the block will be a coal type, otherwise it is a dirt type.

I'm sure there are many other more sophisticated ways to randomly put different block types into the map, but for now this method will do just fine for me. I appreciate everyone who is following this game's progress and I will continue to provide updates as I make changes and improvements to the game.

1 comment:

  1. Would you be willing to share actual (example) code that you are using for the terrain generation?
    I've been searching for days/weeks for C#/XNA specific 2D terrain generation and so far I've found that I should use either midpoint displacement or diamond-square, but I'm having a hard time wrapping my head around either of the algorithms, let alone implementing them in C#. It's not that my C# skills aren't good enough, it's the fact that I've never had to deal with algorithms and I'm not that good at math.

    Any tips, samples and help would be greatly appreciated. :-)

    ReplyDelete