Grid map

For questions about using Classic.

Post » Sun Feb 01, 2009 9:13 pm

If I were to use a grid (tiled) map, what would be the most efficient implementation?

So far I've been experimenting with the array object. It is robust enough, within each element I can store specific tile data even on Z layer (sky/ground/underground). Fine and dandy.

Now, the problem arises when I try to populate the layout with those tiles or their graphical counterparts. If I create an instance of tile graphic for each given tile, the number of instances quickly rises into hundreds! Soon you have thousand objects on the layout. I highly doubt this is the correct approach.

For example, on 640x480 layout with 32x32 tile size there would be 20x15 tiles, which amounts to 300 instances. Now imagine I add flavors, such as transparent objects, terrain features, NPCs on top of all that.

Surely there has to be a more elegant way? I intend to build a game map of 100x100 tiles, smooth scrollable and all that. Now that is a scary amount of instances...
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Feb 01, 2009 9:43 pm

You can cut down a lot of instances by using tiled backgrounds. Things like grass, dirt, roads, etc., are generally made from repeatable textures. Just stretch them to fit, they tile automatically.

And you don't have to, say, have a section of grass on one tile, then a section of road, then another section of grass on the other side... you can have one big area of grass and just lay a road on top of it down the middle.

Just be smart about how you place your tiles and you should be fine. Especially since static tiles, by defenition, generally don't move around. You're not going to get much of a performance hit unless you have thousands of moving objects.

My advice: just build a test level and see how it runs.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest