I have a tile turn based game but they can go through walls because of the way they move. could I have help? Here is the game link: https://arcade.makecode.com/S04492-47953-53637-77083
The problem you’re describing — characters moving through walls in a tile-based, turn-based game — usually happens because your movement logic doesn’t check collisions before moving. In MakeCode Arcade, the physics engine only stops sprites from overlapping if you use walls or collisions correctly.
Here’s how to fix it:
1. Use set wall at
on your tiles
Make sure all the tiles that are “walls” have the wall property turned on. This lets the engine know “sprites can’t go here.”
scene.setWallAt(tile, true)
2. Move with collision checking
Instead of just doing sprite.x += 16
(or whatever your step size), check the tile in that direction before moving. Example:
function canMove(sprite: Sprite, dx: number, dy: number): boolean {
let nextTile = scene.getTile(sprite.x + dx, sprite.y + dy)
return !scene.tileIsWall(nextTile)
}
function moveSpriteIfCan(sprite: Sprite, dx: number, dy: number) {
if (canMove(sprite, dx, dy)) {
sprite.x += dx
sprite.y += dy
}
}
Then use moveSpriteIfCan(player, 16, 0)
for right, -16
for left, etc.
3. Optional: Snap to grid
In turn-based games, it’s often better to snap sprites to tile centers after moving. This avoids them “slipping” through corners or rounding errors.
sprite.x = Math.round(sprite.x / 16) * 16
sprite.y = Math.round(sprite.y / 16) * 16
Basically, the trick is: don’t let the sprite move blindly — always check the tile in the direction first. Once you do that, walls actually stop them. The sprite.x just means go sprites and get the sprites x axis and get the y axis and round is just the round function in Math. when I say function, I mean create a new function, and moveSpriteIfCan to write, and get a sprite parameter, then 2 number parameters that is for dx and dy and in can move, use the same parameters again, sprite, 2 number parameters which are dx and dy, then create a new variable called get tile and = to the get tile at block to the sprites x plus the dx the y for the sprite as adding it by day, then return the variable, then you are done.
Uh, sorry to burst your bubble, but this was a long time ago. I have already solved this problem. But thank you for putting the effort the post. I appreciate it. It makes me feel good to see that some people on the forums care a lot.