adaptive, physics-based tilemap blocks

Godot Version

4

Question

hello!
I’m trying to make an adaptive, physics-based 8x8pixel block tilemap for my game;
adaptive, meaning blocks react and “connect” to the blocks around them, meaning they display different sprites depending on what surrounds them..
physics-based, meaning they are affected by gravity, and fall down.
also each block will need to have health so it could be destroyed by bombs etc…

to be completely honest - I’ve barely got any coding experience. I managed to create the player character but other than that I’m pretty clueless :downcast_face_with_sweat:
I don’t even know if this is something you’d do with a tilemap…
if anyone could help with how to create this sort of tilemap or at least point me towards relevant resources I’d be delighted

thanks in advance!

Making a tilemap where tiles can slide is feasible, but likely to be a bit of a pain. If you want to be able to (say) undermine some blocks and have them fall, you’re probably better off using sprites.

The tilemap would be harder because it’s a fixed grid. You’d have to do tiles falling by making animated tiles, and you’d have to hand-manage the process of them falling from cell to cell. If you do want to use a tilemap, the best answer is probably to use the tilemap for all the stationary blocks, but if a block needs to fall you remove it from the tilemap, place an identical looking sprite over top of where it was, make the sprite fall, and then when it lands, bake that back into the tilemap and remove the sprite.

hmm, I understand.
what if I want the sprite to change depending on the blocks surrounding one block? is a Sprite2D node enough for this?
thanks anyways for the response :heart:

I don’t think you can make the sprite change without writing some code, but you could definitely write code to make the sprite change its look depending on its neighbors.

You can use a Tilemap for that, but it’s not going to be easy with your skillset. I did something like that where I created a Tilemap that changed seasons. It took me like 2 days. I enjoyed it, but it was a ton of math and refactoring, and I have multiple decades of programming experience. Most of my problems came from learning how Tilemaps worked.

@hexgrid 's suggestion is much better for many reasons. Once you get it working, and you learn how to use TileMaps, you can refactor your code to use them if you want.

You can see what I did here if you’re interested. (It was a 2 day Micro Game Jam, and I spent the whole thing on the seasons changing. That part is cool, but the gameplay suffered.)

I’ll try using a sprite and changing it.
thanks a ton for all the help!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.