split stuff out
This commit is contained in:
59
builtins.ts
Normal file
59
builtins.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import {
|
||||
setPixelsInRect,
|
||||
clearScreen,
|
||||
} from "./window.ts";
|
||||
import { font } from "./font.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]);
|
||||
}
|
||||
|
||||
const drawChar = (x: number, y: number, char: string) => {
|
||||
setPixelsInRect(x, y, 4, font[char]);
|
||||
}
|
||||
|
||||
const drawText = (x: number, y: number, text: string) => {
|
||||
[...text].forEach((char, i) => {
|
||||
drawChar(x+4*i, y, char);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
clearScreen,
|
||||
drawSprite,
|
||||
drawText,
|
||||
}
|
Reference in New Issue
Block a user