ftsf / nico

a Game Framework in Nim inspired by Pico-8.
MIT License
624 stars 35 forks source link

Fix fontBlit() wrong clipping area check #100

Closed chitatofish closed 1 year ago

chitatofish commented 1 year ago

The fontBlit() proc checks for the clipping area without applying the camera offset. This causes a bug where although it seems like fontBlit() accounts for the camera when drawing (since it calls pset() to draw), it will not work as expected when the position of the text is outside clipping bounds, even if that position is technically in bounds when accounting for the camera offset.

Additionally, this check is unnecessary, since pset() (which is called by fontBlit()) applies the camera offset, and then calls psetRaw(), which already checks for the clipping area, therefore, we can simply remove this check in fontBlit(), as per my commit.

chitatofish commented 1 year ago

Just to be extra clear, fontBlit() DOES account for the camera when drawing, as it calls pset() (which does account for the camera). To test this, you can move the camera slightly down and to the right (say, setCamera(50, 50)), and try something like print("Test", cameraX, cameraY), the text will be exactly on the top left. The problem is that although it does account for the camera when drawing, it still performs a check that does not account for it.

ftsf commented 1 year ago

thanks!