• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Question about tiling

S

Spelfantast

Guest
Hi.

I been trying to make a platformer in gamemaker 1.x - thinking about upgrading to gamemaker 2.
I have a wall object which is just a black square. I have also made a tileset.
When I make a room, I've made the layout using the wall object, stretching it out to fit the walls, stairs, ground and ceilings. After that I have put the tile-sets on top of it, as a way of avoiding having so many different objects in the world for every custom tile - like how a wall should look different depending on if its a corner, ground, or ceiling for example.

However, I'm starting to wonder if there is a faster way to design rooms. Can I somehow make tiles act as platforms or obstacles on their own, without any underlying wall object? Can I make smaller or bigger tiles that only act as a wall object in the space they are actually occupying on the screen without making a similar size wall object lie underneath?

I see there are autotiling in gamemaker 2 - but does it also include a function to make a tile act as an object/wall.

I would love to hear how you work with tilesets, if you have actual drawn objects for stuff like doors and chests and ladders or if you use tilesets for them as well but somehow manage to set the tiles to have properties?

Thank you so much in advance.
 
Y

Yazuka

Guest
Within the room editor in GMS2 you can make two tile layers, one for your actual tilset where you'd place all your graphics as intended and another tileset with collision tiles. Within your collision tileset you can make multiple tiles for different things such as walls, floor, water etc and then once you've placed all these then hide the tile layer for your collision, then within your collision check you'd do something like:

Code:
//Get the element of the layer
var tilemapElement = layer_get_id("Collisions");

//Get the layer ID from the above element
var tilemap = layer_tilemap_get_id(tilemapElement);
 
//
var tileExists = tilemap_get_at_pixel(tilemap, xPos, yPos) & tile_index_mask;
You would then check what tileExists is, 0 being nothing as you can't have a tile at this position, 1 being floor, 2 being wall, 3 being water etc which would satisfy your requirement of doing collisions within tiles and not having to use an object to check this.
 
D

Deleted member 13992

Guest
Tile-based collision is planned in the future for GMS2, if I recall correctly.

I do somewhat the reverse you do. Not better or worse, but easier to iterate apon. At least for me. I place my tiles first (via autotiling or hand-placed), so I can immediately see how it looks. Then I wrote a script that on-startup, it cycles through every single tile in the room, and places an invisible collision block if the tile needs it. It's very fast, fraction of a second for a room thousands of tiles wide/tall. This has it's upsides and downsides.

Downsides
-Lots of wasted blocks, since I don't stretch them to cover a wall like you do. One block per tile. I get around the performance hit by disabling all instanced blocks outside of the view, so collision only has to deal with a few, even if thousands were generated at runtime. I'm sure it could be optimized further. I'm thinking of adding a stretchable invisible block that could cover just where you need collisions, and adding a rule "only add blocks within this".
-Updating the rules of which blocks do and which blocks don't is a bit tedious, especially if you move them around in the tileset. Make a change, and tile #57 isn't the old #57 anymore, so I need to be careful and plan tilesets ahead to leave space for additions without moving tiles around. Or develop a system for easy editing.

Upsides
-Very fast to iterate! If I don't like how a platform looks, or how it plays, I just change the tiles without worrying about invisible wall blocks.
-I use the same runtime tile cycling system to enhance other things, like adding tile variation, and adding particles around only certain tiles.
 

Kyrieru

Member
Look up "tile map collisions in GM2 GM wolf"
has a decent video on it.

Also, to iterate on what muki is saying (or clarify). With the tile collision code I use, you need to check for a specific tile layer to use it for collisions. That means that unless you're using only 1 tileset/layer, you wont be able to do what you want, which is automatic collisions.
So to get around this, you have one "solids" tile layer and as many "visual" tile layers as you want. At the beginning of each room, you detect which visual tiles are in each cell, and you add invisable tiles to the "solids" layer, which is invisable.

There is very little loss in performance, even if you have a screen full of tiles, so long as they are invisible.

However, populating every tile in the room is slow, and you will see a split second delay. To get around this, I populate the tiles that are within the view first, and all other tiles are populated step by step as opposed to all at once with a loop.
 
Top