Topic was automatically imported from the old Question2Answer platform.
Asked By
Cashwarrior1
I’m just trying to make one of those sliding block puzzles but instead of pushing a block, you press a direction and then your character slides in that direction until it hits a wall. I’m new to coding and know nothing about the language so I rely on tutorials but there’s none for sliding block puzzles apparently. If you could respond with a code and explanation of the code, that’d be appreciated!
Rely on physics. Create your blocks with collision shapes. Use TileMap to help with level creation and set certain types of tiles as blocking. When the player moves into a block, apply a force to it and then fine tune the details. (Magnitude, friction, etc.) Physics introduction — Godot Engine (stable) documentation in English
Handle the game logic separately from the visual representation in a grid matrix of some type and use the engine to render visuals. This method will give you total control over the logic, but it may be a bigger challenge to get animations working correctly, especially if you plan to have pushing a block create a chain reaction.