How to build in godot 2d?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By I_need_help

Ive seen people build using tilemaps in games like stardew valley or terraria, where the player uses the mouse to place blocks in-game like in this or this, rather than in the pre-game editing screen like these videos show.

this seems to be a skill that every godot dev knows and i dont really know how to describe what i need accurately so sorry if its a bit confusing, but i hope it works

:bust_in_silhouette: Reply From: skysphr

Hook the player mouse input and call Tilemap.set_cell() with the appropriate x and y to add, change or delete tiles on runtime.

what do you mean “hook player mouse input”

I_need_help | 2022-03-27 14:26

Sorry for late reply but the idea is to have a block of code execute when the user presses a button, for example inside _input(event), you can call something like if event is InputEventMouseButton and and event.pressed and event.button_index == BUTTON_LEFT:. Of course the exact code will depend on your implementation and use case.

skysphr | 2022-04-02 18:12