I started creating a top-down 2D tile based game and i'm currently doing the map system side of the game. I already made several modules, such as loading the map, dividing it in chunks, and each chunk has its own Vertex Array which contains all the tiles in this chunk. This works pretty well, but for now, there is no tile transitions, as seen in this screenshot :
![tumblr_inline_nai7fdo1Vo1rxgxsk.png](http://media.tumblr.com/d946700971c61efd4760a8572943b490/tumblr_inline_nai7fdo1Vo1rxgxsk.png)
What i want is that tiles have a variant texture when they collide a tile with a different ID (dirt/sand or sand/water for example, but i think you got it). I made a "test" texture (and removed the sand for now) :
![VGOHLW6.png](http://i.imgur.com/VGOHLW6.png)
When i made this tiles i thought about first drawing the entire tile, and then, in another function, detect if it is needed to change the border, than if it is needed, taking a border and drawing it on the vertex array. It sounds simple but i can't figure out how to do it, i tried all the afternoon to do this, in verifying every tiles if they need borders with the one on their right, down, and down-right, to minimize the loop. This way, if the current tile and the tile on the right are different, it will draw the right border of the current tile, and the left border of the tile on the right.
It looks to me it is a kind of low resources use method to do it, but everything i have done so far is a buggy mess.
Any suggestions on how to do that ? I'd really appreciate it, thanks.
PS: I'm sorry if i made some grammar errors, english is not my native language.