61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import {
|
|
mainloop,
|
|
frame,
|
|
setPixelColor,
|
|
clearScreen,
|
|
setPixelsInRect,
|
|
} from "./window.ts";
|
|
|
|
// deno-fmt-ignore
|
|
const sprites = [
|
|
[
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
],
|
|
[
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 3, 3, 1, 1, 3, 3, 2,
|
|
2, 3, 3, 1, 1, 3, 3, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 1, 1, 1, 1, 1, 1, 2,
|
|
2, 3, 3, 1, 1, 3, 3, 2,
|
|
2, 3, 3, 1, 1, 3, 3, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
],
|
|
[
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 4, 4, 4, 4, 5, 5, 2,
|
|
2, 4, 4, 4, 5, 5, 5, 2,
|
|
2, 4, 4, 5, 5, 5, 6, 2,
|
|
2, 4, 5, 5, 5, 6, 6, 2,
|
|
2, 5, 5, 5, 6, 6, 6, 2,
|
|
2, 5, 5, 6, 6, 6, 6, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
],
|
|
]
|
|
|
|
const drawSprite = (x: number, y: number, spr: number) => {
|
|
setPixelsInRect(x, y, 8, sprites[spr]);
|
|
}
|
|
|
|
await mainloop((t) => {
|
|
console.log(t/1000);
|
|
clearScreen();
|
|
for (let i = 0; i < 256; i++) {
|
|
drawSprite(Math.floor(Math.random()*120), Math.floor(Math.random()*120), 0);
|
|
drawSprite(Math.floor(Math.random()*120), Math.floor(Math.random()*120), 1);
|
|
drawSprite(Math.floor(Math.random()*120), Math.floor(Math.random()*120), 2);
|
|
}
|
|
setPixelColor(0, 0, 3);
|
|
setPixelColor(0, 127, 4);
|
|
setPixelColor(127, 0, 5);
|
|
setPixelColor(127, 127, 6);
|
|
frame();
|
|
});
|