kill counter fixed. 8x8 anf 8x16 fonts added. terrain slides are aminated.

This commit is contained in:
catarrh committed 2026-07-25 19:24:12 +03:00
1 parent 43ee0d9150
commit e8a79c2a81
9 files changed
+80 -20

No files matched your search

+37
View File
@@ -72,6 +72,43 @@ export function collapseTerrain(ctx, ) {
cacheImageData(ctx);
}
export function startCollapseTerrain(terrain) {
return {};
}
export function collapseTerrainStep(terrain, state) {
const {width, height} = terrain.canvas;
const imageData = terrain.getImageData(0, 0, width, height);
const data = imageData.data;
let anyMoved = false;
for (let y = height - 2; y >= 0; y--) {
for (let x = 0; x < width; x++) {
const idx = (y * width + x) * 4;
const belowIdx = ((y + 1) * width + x) * 4;
if (data[idx + 3] > 0 && data[belowIdx + 3] === 0) {
data[belowIdx] = data[idx];
data[belowIdx + 1] = data[idx + 1];
data[belowIdx + 2] = data[idx + 2];
data[belowIdx + 3] = data[idx + 3];
data[idx] = 0;
data[idx + 1] = 0;
data[idx + 2] = 0;
data[idx + 3] = 0;
anyMoved = true;
}
}
}
if (!anyMoved) {
cacheImageData(terrain);
return true;
}
terrain.putImageData(imageData, 0, 0);
return false;
}
export function isTerrain(ctx, x, y) {
const index = coords2index(ctx.canvas.width, x, y) * 4;
return cachedImageData.data[index+3] > 0;