For those who've made tile engines...

Get help using Construct 2

Post » Mon Jul 01, 2013 2:24 pm

My design for the map: A 64x64 grid of tiles, each represented by 32x32 pixel tiles that are all sprites. The map data will be held in a 2D array, and there will be a function that runs whenever something changes that will update the sprite-tiles to reflect the data in the array. The player's view window of the map will be only 10-15 tiles in size and will follow the player, generally, wherever they go on a particular map.
When the player goes from one 64x64 map area to another, the array will be filled with the new data, and the tiles will be updated.
Now that you (hopefully) have an idea of how this is supposed to work, I am wondering if there is an easier way to place each of those tile sprites (all 64x64=4096 of them) in the editor? Or will I have to script it in runtime to set the grid up?
Also, do you think having 4096 relatively inactive sprites will run slow or cause other problems? Any suggestions for a better method of having dynamic tiles?
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Mon Jul 01, 2013 2:31 pm

I personaly use rexrainbow's plugin : TMXimporter, and prepare my tile maps in TMX. Look at this thread, there are a lot of examples.
Hope it helps !
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Mon Jul 01, 2013 2:44 pm

Wow, that's a cool plugin!
Unfortunately, It won't help me. In my initial post, I should have mentioned this game is a roguelike, where maps are generated dynamically, not premade.
I did have some more thoughts about the engine design, though. I'm worried FPS will suffer with 4096 sprite tiles. I am already using R0J0hound's canvas plugin for something else in this project. I think I could have a big canvas object, 4096x4096 pixels, and then have the update function read my map data array, then rubber stamp the correct tile image onto the canvas at the right place. Any part of the map that can be collided or otherwise interacted with will have to be layered on top of this canvas, however. More complicated, but should perform much quicker I think.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Mon Jul 01, 2013 2:54 pm

@Yttermayn
The tile count could be a problem yes. Not storing it in arrays, arrays are fast, but 4k instances can be laggy, depending on the system.
If it was me, I would prepare my tile types and store it into the arrays, then build only a screen and a half (tiles covering the screen +50% of its size). As your movement are tilebased (or can be assimilated to), you can update your layout every movement, with something like this :
- when move right, get the left column, move it to the right of the layout, change the frame of every of its tiles to what is said in the array (and maybe more than just changing frames, like spawning monsters, ...)
- same for the other directions
With a loading system like this, you could virtually have billions of tiles without lagging, as the object count won't go up and you would recycle most of the objects.
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Tue Jul 02, 2013 2:34 am

That is an intriguing idea. I think I did something like that years ago in C++, I will have to think on this. Thank you!
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Jul 02, 2013 5:08 am

Here's one such way to implement it:
https://dl.dropboxusercontent.com/u/5426011/examples18/tile_engine.capx
With 32x32 sized tiles then a total of 336 objects would be used.
B
85
S
27
G
85
Posts: 5,067
Reputation: 57,868

Post » Tue Jul 02, 2013 4:04 pm

wow amazing, and you can probably still use the tmximporter for populating the array..

ps: hm after rechecking, im not sure how you should make the array with grounddata

vtrix2013-07-02 16:08:33
ImageImage
B
65
S
19
G
7
Posts: 814
Reputation: 9,691


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], KailSaisei, Magistross and 10 guests