kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

bug: level raycast is messed up when the tiles don't have `topleft` anchor

Open dragoncoder047 opened this issue 1 year ago • 2 comments

add to mazeRaycastedLight example

const level = addLevel(
    createMazeLevelMap(15, 15, {}),
    {
        pos: vec2(100, 100),
        tileWidth: TILE_WIDTH,
        tileHeight: TILE_HEIGHT,
        tiles: {
            "#": () => [
                sprite("steel"),
                tile({ isObstacle: true }),
+               anchor("center"),
            ],
        },
    },
);

const bean = level.spawn(
    [
        sprite("bean"),
        anchor("center"),
        pos(32, 32),
        tile(),
        agent({ speed: 640, allowDiagonals: true }),
+       anchor("center"),
        "bean",
    ],
    1,
    1,
);

and the raycasted light bubble will be in the wrong spots

dragoncoder047 avatar Oct 10 '24 22:10 dragoncoder047

Also, it doesn't obey area scales

dragoncoder047 avatar Oct 10 '24 23:10 dragoncoder047

This is because it is a voxel raycaster, it traces rays along the voxels of the level (the grid) and looks only at grid tiles which are hit. This example is set up to render some tiles as solid. These tiles lie on the grid, it doesn't matter where the sprite is. It doesn't look at the sprite. The raycaster only sees solid tiles and areas, not sprites.

mflerackers avatar Oct 10 '24 23:10 mflerackers