What is this thing?

0 What is this thing? 0
This is just a place for projects to honorably get canned. Thrown out assets, projects that break which is unfixable... by me at least. Projects in which I have lost interest or drive. In many ways it is a sad place - but I'd rather see it as a really happy place, where things that would've never seen the light of day got to go outside anyway. Even though they are ugly - broken. Even though the creator has been mad at them for the most part.
However they know- they've got to know- they know that the creator is merely mad at himself, disappointed even. These small lively things are loved and they are all part of a journey.
Enjoy them! And take them for what they are.

fredag den 9. maj 2014

Auto Multi Tile Placer - fancy

I hit quite a problem the other day when I started to integrate a **** into Proxemit at the end. It desired for me to place tiles relative to each other. The easy solution was to have only one kind of tile, and I did have only one kind of time for a short while.

It looked something like this:

But that was to absolutely no satisfaction. So the only reasonable thing to do was to spend the entire evening coding an "intelligent" tile placer. Which sees corners, straights etc.

The way I did this, though hacky, I guess, was to have a thingy place hundreds of tiles in a pattern derived from a 32 x 32 bitmap that was actually the blueprint for the ****. So if the bitmap had a pixel at a given position, the thingy would automatically place a "block" at that position relative to the grid size of the game.

A pixel at position 3 x 5 in the blueprint bitmap would result in a "block" being placed at 3*32 x 5*32 pixels relative to the ****. Pretty cool. And simple. Hacky.

When all the needed "blocks" had been placed, each "block" would then run their own little code. That code basically checks its surroundings. First in direction 0, which is straight to the right. Then direction 45, which is upper right, then 90, which is straight up, etc.

Each time the "block" saw another block it would count +1 in a variable called "blocks", each time it didn't see anything it would count +1 in a variable called "voids".

After having gathered the needed intel to form a sort of matrix of where there were blocks and where there weren't, it would determine in which average direction there were blocks.

Average direction of "voids"/"blocks" in degrees:
1: 247-------------2: 270-------------3: 315

So if the little block saw 5 blocks to the right,45,up,135,left it would have an average accumulated cluster of blocks in the direction of 90, or straight up. So the void would naturally be at 270, or straight down. After that assessment it was just a matter of "skinning" the individual "blocks" with a corner graphic if it was at a corner, or a straight graphic if it had neighbors whom desired it to be straight. 

The result looks a bit like this - 
- but not really, you'll have to play the game to see. -_-'

The ones inside the shape are a bit misleading, they are actually to be skinned black, so they are present but not visible. 

I know it is not very groundbreaking, but I felt like a freaking god when I nailed that one!

Ingen kommentarer:

Send en kommentar