Change the size of tilemap selector without changing the whole size of the tilemap? + collisions

0 favourites
  • 7 posts
From the Asset Store
220 Food Sprites in 16x16 pixel size. Perfect for items for a retro style game.
  • Hello!

    Check this out:

    This tilemap has tiles that are 256x256. I want to be able to change the size of my selector to 64x64 (divide each tile evenly into 4x4) so that I can 'select' the 'empty' parts of the tile and add collisions to those parts only without changing the size of tiles that have already been placed.

    At 256x256 you can imagine my tilemap is pretty large (I'm using raster images not pixel art and want them to be of a certain quality. hence the size) and I would rather draw with 6 tiles at 256 than 96 tiles at 64.

    Ultimately, this is for a maze and I'm trying to make it so that the empty parts of each tile register the collision so that the player doesn't move outside the art.

    I've tried the 'layer another tilemap on top and make it invisible' and again, a 64x64 size tile on my giant map makes this a ridiculously tedious task. Also, I would eventually love to figure out how to generate the maze map randomly tile by tile instead of 'scene by scene' as I have currently done. A topic I'll create later if I need to, but for now it will help to figure this collision thing out.

    Thanks for your help

  • You can edit collision polygons for each tile if you double-click it in the tilemap bar. However, this may not work for tiles which have walls on opposite sides, since it's not possible to have two polygons.

    I would use another (invisible) tilemap with 64x64 px tiles just for collisions. You can draw walls on it manually or fill it with an event.

    Check out this demo:

    howtoconstructdemos.com/using-an-invisible-tilemap-as-an-obstacle-map-for-pathfinding-capx

  • Yes collision polygons don't work for me here because in some tiles I would need more than one polygon.

    I've experimented with a second invisible tilemap and drawing it manually and it's not efficient. I currently have drawn out 5 quite large maps with the larger 256x256 tiles where drawing the smaller 64x64 tiles on top of is too time consuming because eventually I would love a larger variety and drawing them out by hand doesn't make sense. I haven't figured out random generation yet, which would help, but doesn't solve the collision problem.

    It looks like in the demo you shared the tilemap was drawn manually over a sprite. You mention I can 'fill it with an event'. What do you mean by that/how? If I created a 64x64px tilemap and marked tiles 0 through 3,4,7,8...etc as tiles that register collisions how could I then 'attach' them to the larger 256x256 tiles? That's not possible is it? Here's a picture:

    So in the 256x256 tilemap, tile 0 would coincide with tiles 0-15 on the smaller 64x64 tilemap and anywhere tile 0 is so are tiles 0-15?

    Maybe I just have to pick a completely different approach? It's not possible to split the art up in an efficient to draw way and register collisions properly. I have clear areas of transparency in my tilemap. Is it possible to say 'whatever is transparent you can't touch it?

    Maybe it's just best to fully redraw the assembled maps, have fewer of them, and layer sprites as navigable or collisions?

    I was hoping for some relatively detailed art which is why I went the tilemap route. Maybe they're not great for that?

    Thank you for your help!

  • Here is a demo. It uses collision polygons in the main tilemap to automatically fill the collision map.

    dropbox.com/s/squgt33uyfuraer/AutoFill_collisionMap.c3p

  • Thank you so much for doing that Stan! This is exactly what I was describing!

    I really want to make sure I understand what is happening here and there is one bit in the first start of layout event I'm not sure I get. I'm surprised that in so few events this works.

    Start of layout. This is setting the size of the obstacle map display width and height? to 100x100? Where does 100x100 come from? This isn't just setting it though it's also drawing them right? So 100 tiles across and 100 tiles down. It's filling a 100x100 'grid' with tile '0' in this case.

    Then, the display width and height of 100x100 (or 0 to obstacle map width/height-1)is what the next event is looping from for x and y which is picking that position on the main tilemap using the same x and y positions from the loop. Overlapping is another way to say collision then? So anywhere there is an overlap we are not drawing the tile(erasing).

    I did test changing the collision polygons to see how it would effect the obstacle map erasing and it makes sense. So this works so well because the 64x64 tiles fit evenly and nicely within the 256x256 tiles? It would be a different story with art that was a bit more organic then.

    My last question about it is the x on the layout drawn with the obstacle tile. Is that just for illustrative purposes?

    Thanks again for creating and sharing that demo.

  • It's filling a 100x100 'grid' with tile '0' in this case.

    Yes, just filling the whole map with solid tiles. If your map is big, you can change the numbers to 10000x10000, it doesn't need to be the exact width and height.

    The next loop is looping for each tile on the obstacle tilemap. If your obstacle tilemap is 6400x3200 px, then the loop will run 100x50 times.

    It checks if each tile on the obstacle tilemap is overlapping the main tilemap. If it does, the tile on the obstacle tilemap is erased.

    My last question about it is the x on the layout drawn with the obstacle tile. Is that just for illustrative purposes?

    This is just for you to see that there is another tilemap in the layout editor.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Fantastic! Thank you so much for your help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)