Thursday, June 9, 2011

Dynamic Block Texturing Is Up

Great success! After too many days of struggling with the code to get the blocks updating their textures based on what blocks are neighboring around them, I finally have a working build that looks really good. The main trouble I was originally having was that I was trying to test for too many cases, which overcomplicated the entire thing.

What I first tried to do was test a block's eight neighbors to determine which texture should be used for that block. This was over-complicating the process; not only did I have to have the six textures for the simple left, right, top, bottom scenarios, but I also had to have textures for all of the possible corner cases. This left me very frustrated and in need of something else to do.

The solution to my problem was very easy in fact. What I did was shrink the block size from 32 x 32 to 16 x 16 and dropped the corner cases / corner textures. Please note that when I say corner textures I'm referring to a piece that has a corner cutout of it. I also created new textures for the blocks with edges that seemingly run together. This makes the cases in which there is an L-shape still look good in the corner spot because the top and right textures almost run together.

Other things that I did include changing the resolution to classic 800 x 600, changing the player sprite from a square to a thinner, taller rectangle (to more closely resemble the final sprite's size), and am running an UpdateBlock() method every time the player removes and adds a block (which updates the surrounding blocks' textures based on which action the player made).

The game is coming along nicely in my opinion. Next things on the list include better terrain generation, more types of blocks, player inventory, and many more things that I don't want to list for fear of getting overwhelmed by it all.

For now, please enjoy a screenshot of my small (but big to me) victory.

1 comment:

  1. If you dropped your corner cases, then how did you detect which blocks ran together and such? It seems to me you have more than 1 texture, so some kind of check must be in order to choose which one, right?

    ReplyDelete