TinyCircuits / TinyCircuits-Tiny-Game-Engine

MicroPython game engine for TinyCircuits Thumby Color
GNU General Public License v3.0
10 stars 2 forks source link

Positions can become visibly misaligned by one pixel for nodes of specific sizes #84

Closed transistortester closed 3 months ago

transistortester commented 3 months ago

Minimal example:

import engine_main
import engine
from engine_nodes import CameraNode, Rectangle2DNode
import engine_io

camera = CameraNode()
sprite = Rectangle2DNode(width=112, height=16)

while True:
    if engine.tick():
        if engine_io.A.is_just_pressed: break #quit

        if engine_io.DOWN.is_just_pressed:
            sprite.position.y += 1
            print(sprite.position)
        if engine_io.UP.is_just_pressed:
            sprite.position.y -= 1
            print(sprite.position)
        if engine_io.RIGHT.is_just_pressed:
            sprite.position.x += 1
            print(sprite.position)
        if engine_io.LEFT.is_just_pressed:
            sprite.position.x -= 1
            print(sprite.position)

Move the sprite by one pixel at a time with the d-pad. For this size specifically, when the position goes beyond -7 in either axis, the position becomes off by one pixel (-7 and -8 appear in the same place). Changing the size of the rectangle can make the misalignment appear at different positions. For instance, a width of 110 changes it to -9.

This is especially visible with nodes like GUIBitmapButton2DNode as the text itself may move as expected while the bitmap does not.

Video of this issue happening:

https://github.com/user-attachments/assets/eb761879-4e09-4c45-80d8-11bb888b4f00

TinyCircuits commented 3 months ago

Seems to be fixed as of: 9ff0c7c