2025-08-30 01:23 UTC
I also implemented the collision system in ECS following https://www.fatoldyeti.com/posts/roguelike4/
But some places I could go through walls, and sometimes I was blocked by some invisible blocks.
I couldn't see the pattern and the tiles seemed to be at the right places. So I decided to debug it the classical way: `printf` to the rescue!
`.` are the floor and `#` are the walls. They should be all around, but clearly, they aren't. There is a pattern to figure out, but it eluded me until I counted it.
For performance reason, all the tiles were added in a slice, instead of slices of slices.
I added them one after another in a double loop.
Basically, I inverted x and y, and so it was creating a slice of column first then rows. But I was displaying them and computing them by rows first and column next.
Pretty basic error, but the debug print made it all clear very fast.
#golang #g3n #roublard #3d #RogueLike
Replies (1)
-
@dolanor@hachyderm.io 2025-08-30 01:30
it highlighted a problem where the display didn't show the logic, which is a code smell to me, and that's something I introduced while adapting to 3D. On ebiten, the entities will be drawn every frame based on their location. On g3n, I set their position at creation, and then the engine will render them where they are positioned. But the collision would happen on another part. I wonder how I can make sure that WYSIWYG without coupling logic too much.