Camera and outline rect functions

This commit is contained in:
dylan
2023-05-10 00:06:08 -07:00
parent b394f81477
commit e955a4c00d
6 changed files with 59 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ import {
setPixelsInRect,
clearScreen,
fillRect,
cameraPos,
} from "./window.ts";
import { Font, font } from "./font.ts";
import { keyDown, keyPressed, keyReleased } from "./keyboard.ts";
@@ -10,6 +11,7 @@ import { resetRepl } from "./repl.ts";
import { COLOR } from "./colors.ts";
import { getSheet, getCodeSheet, getMapSheet } from "./sheet.ts";
import { saveCart, loadCart } from "./cart.ts";
import { outlineRect } from "./util.ts";
let spritesheet: number | null = null;
@@ -73,16 +75,23 @@ export const measureText = (text: string) => {
return measureTextFont(text, font);
}
export const camera = (x: number, y: number) => {
cameraPos.x = x;
cameraPos.y = y;
};
const faux = {
// Graphics
cls: () => {
resetRepl();
clearScreen();
},
camera,
sprsht: useSpritesheet,
spr: drawSprite,
txt: drawText,
rect: fillRect,
rectfill: fillRect,
rect: outlineRect,
map: (mapSheet: number, tileX: number, tileY: number, screenX: number, screenY: number, tileW: number, tileH: number) => {
const originalSpritesheet = getSpritesheet() ?? 0;
getMapSheet(mapSheet).forEach(([sprSheet, spr], i) => {