Part 1 of 13 in Ghostveil
Another game, another idea
The first night of Ghostveil, a puzzle game in Flutter and Flame, when every piece was still a coloured square.
Another game, another idea. Since 2023 I'd started three games in Flutter and Flame, all of them platformers. One Sunday night in May 2025 I started a fourth, Ghostveil, and this one was a puzzle on a grid: a red square that moves one tile per arrow key, a block to push, a hole to fill and a turnstile to turn. By the time I stopped, all four worked, more or less.
There's no art.
I drew a ten by ten room in Tiled and put every piece on the object layer, even the walls and the player, and each one comes out as a coloured rectangle: the player is red, the turnstile has four green arms and the stairs are the blue square tucked into the top right corner of the turnstile's box.
Walk into a block and it moves one square, as long as the square beyond it has no wall or block in it. Those are the only two things that stop a push, so a block will slide over a turnstile arm or the stairs.
A hole stops you until a block goes into it. Then the block is removed and the hole is repainted:
void fill() {
isFilled = true;
paint.color = Color(0xFF111111); // Change color to indicate filled hole
}
That's the background colour, so the hole is still there but looks just like the floor, and you can walk over it.
The turnstile
The turnstile takes up a three by three square, with an arm in the middle of each side and the centre and corners empty. Push an arm and all four try a quarter turn about the centre; if none of them would land on a wall or a block they turn, and you move into the square the pushed arm started in. Otherwise nothing moves.
I rotate each arm's offset from the centre, :
Here is how far the arm sits to the right of the centre square and how far below it, and the matrix in the middle is the quarter turn: multiplying by it swaps the two and changes the sign of the new .
List<Vector2> getNextRotationPositionsClockwise() {
return arms.map((arm) {
final local = arm.position - Vector2(tileSize, tileSize);
final rotated = Vector2(-local.y, local.x);
return position + rotated + Vector2(tileSize, tileSize);
}).toList();
}
In ordinary maths that turns anticlockwise. On a screen counts downwards, so here it turns clockwise, and every push turns the arms clockwise whichever side you push from. Because the arms form a plus, a quarter turn leaves the same four squares filled, with each arm in the next one's old square:
The arms look unchanged after a push, but I move into a square that another arm now fills. I come at the west arm from above and press down. The west arm swings up to the north square, the south arm swings into the square I've just stepped into, and I'm standing on it.
Nothing checks the centre square either, so one more step right puts me inside the turnstile, with an arm in the west square again behind me.
The stairs are drawn, but walking onto them does nothing. Nothing stops me walking off the edge of the map into the dark either, and there's no undo, so the only way to put the block back is to quit and start the game again.