Freitag, 14. September 2012

Pasting tilemaps together

Yesterday, I managed to put 4 tilemaps in a 2d array to hold them though I wasn't really that successful at all.

See this neaty screenshot of my paramount achievement:

 A concept of tilemap that didn't work.

This is were I started off today, and having only a bit experience with arrays and that stuff (lists of enemies etc. are quite easy but I never played around that much with arrays of coordinates) it took me quite a while to get the system working. But, finally, I think I got it. At least there haven't been any new bugs around for several minutes ^^

So this is what the same map & seed look like now (zoomed out a bit further):

Finally, a continuous map!

I don't know if it's a great idea but I use one 2d array to hold 4 tilemaps – the primary tilemap the player is in and 3 other tilemaps where he can go – and one bigger array with these 4 tilemaps to render the scene.
An Example: I have a tilemap consisting of 7x7 tiles: 1-1, 1-2, 2-3 etc.
The tile where my (atm non-existing) avatar will be held in array[0,0], the rest around it:

[0,0] = 4-4  ||   [1,0] = 5-4
[0,1] = 4,5  ||   [1,1] = 5-5

When I go from 4-4 to 5-4, after some tiles the tilemaps will get shifted within the arrays, so that [0,0] will hold the new array I'm in:

[0,0] = 5-4  ||  [1,0] = 6-4
[0,1] = 5-5  ||  [1,1] = 6-5

If I now decide to go upwards, the tilemaps will be shifted again, this time a bit earlier, depending on how near I am to the border. I 'm still in 5-4, but the arrays now are:

[0,0] = 5-3  ||  [1,0] = 6-3
[0,1] = 5-4  ||  [1,1] = 6-4

It took me quite some time to get this working, espacially the transfer was quite buggy, but I think now I got it working.

I also played around a bit with tilemap size and world size (i.e. how many tilemaps will be there) and found out the tilemaps shouldn't be larger than 80-85 tiles or else the performance will break down dramatically when scrolling diagonally. I think this has something to do with the way I check if I'm switching to a different tilemap.
On the other hand, having a lot of tilemaps doesn't seem to be a problem. Even with 50x50 tilemaps I had default 60 fps, though constructing the map takes a lot of time. But this will probably be because I create the whole map, not just a part of it and the rest on the go. Maybe I'll check that out tomorrow.

And because I'm so happy, here another screenshot of a map with a different seed:

From far away, this actually doesn't look that bad.


And that's it for today. Next I'll either try world creation on the fly, or I'll look how I can implement 3 to 5 levels of height.

But now a little killy killy antes de sleepy sleepy.

Good night,
Sleeptaker...

Keine Kommentare:

Kommentar veröffentlichen