Tileset image-based map loader

For questions about using Classic.

Post » Wed May 09, 2012 1:24 pm

So I'm working on a tile-based map system. It will (eventually) load tiles from an array specified in an ini, though I haven't got around to that yet because of one rather big problem.

So I'm using Image Manipulator to load the tileset image in data/tiles/debug.png. Then I cut the tiles up using crop. Then I use Image Manipulator to copy its image onto a sprite. But once I do this, every instance of that sprite uses that image, overwriting the previous one. I don't want this. I want the sprite to have a unique image when it is created, but I don't know how to do it. Should I even be using the sprite object? I don't know.

Anywhere, here's the project folder with the .cap. If you can find the time, please take a look at the events in the Engine layout and tell me what I'm doing wrong that causes this to happen.
http://dl.dropbox.com/u/28629176/gamedev/game.zip

I also noticed that my "Tiled Background" object isn't tiling at the correct size. Though I'm using events to load a 24x16 image (in data/floors/tiles.png) into it, it tiles at 23x15. This doesn't exactly halt the progress of the project but is there a way to fix this, too?

Thanks anyway.solar2012-05-09 13:31:35
B
4
Posts: 14
Reputation: 328

Post » Wed May 09, 2012 1:34 pm

You're better off using a tiled bg object for your tileset and image offset to get your tiles!
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Thu May 10, 2012 6:33 am

[QUOTE=Tokinsom] You're better off using a tiled bg object for your tileset and image offset to get your tiles![/QUOTE]
What are the implications on memory usage for loading the tileset texture for every tile, though?

EDIT:
So it's definitely not possible it seems. I don't like the idea of loading the tileset texture into, maybe ~1000 tiled background objects and I don't think it would work anyway since I'm using irregular 24x16 sized tiles. Any other bright ideas on how tile maps could work in Construct?solar2012-05-10 17:45:38
B
4
Posts: 14
Reputation: 328

Post » Thu May 10, 2012 7:07 pm

I'd load every single tile into a sprite animation. You could save a lot of events by looping through the frames. I'd suggest you take a look at the (old) forums, too.
B
59
S
7
G
2
Posts: 93
Reputation: 4,228

Post » Thu May 10, 2012 7:31 pm

[QUOTE=solar] [QUOTE=Tokinsom] You're better off using a tiled bg object for your tileset and image offset to get your tiles![/QUOTE]
What are the implications on memory usage for loading the tileset texture for every tile, though?

EDIT:
So it's definitely not possible it seems. I don't like the idea of loading the tileset texture into, maybe ~1000 tiled background objects and I don't think it would work anyway since I'm using irregular 24x16 sized tiles. Any other bright ideas on how tile maps could work in Construct?[/QUOTE]
You didn't get the idea. You'd create just one tb-object and load the tileset into. Then you use as many instances of this tb as you need. In your example, every tb instance would have that 24x16 size while the actual tile from the tileset is selected in runtime using the image offset actions of the tb. Picking of the tb-instance can be done in various ways (for each-loop, pv, uid, etc.). This way you will have exactly one copy of the tileset in VRAM. This method is more or less what you would use in tilebased game makers.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu May 10, 2012 7:35 pm

Thanks for elaborating, Tulamide. I was on my phone and didn't want to type all of that out ^^;
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Fri May 11, 2012 5:31 am

looks like I'll at least have to hold onto the Image Manipulator object to check the tileset image size

but Tiled Background's set offset isn't even doing anything for me, I'm calling it but nothing is happeningsolar2012-05-11 06:45:42
B
4
Posts: 14
Reputation: 328

Post » Fri May 11, 2012 7:34 am

The texture must be a power of 2 size for image offset to work. You can use empty space if needed.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Fri May 11, 2012 7:57 am

[QUOTE=Tokinsom] The texture must be a power of 2 size for image offset to work. You can use empty space if needed. [/QUOTE]

I can't say I like that or having empty space but at least it works

Now there's only one problem left:



Why does this happen?
B
4
Posts: 14
Reputation: 328

Post » Fri May 11, 2012 1:20 pm

Eh..that's interesting. Might be due to the weird size. Tiles in general are 8x8,16x16,32x32, and so on.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests