Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dragoncoder047 opened this issue Oct 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dragoncoder047
Copy link
Contributor

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 dragoncoder047 added the bug Something isn't working label Oct 10, 2024
@dragoncoder047
Copy link
Contributor Author

Also, it doesn't obey area scales

@mflerackers
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants