kaplay
kaplay copied to clipboard
bug: level raycast is messed up when the tiles don't have `topleft` anchor
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
Also, it doesn't obey area scales
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.