Fix map stuff, and implement builtin funcs for it

This commit is contained in:
dylan
2023-05-09 23:50:27 -07:00
parent ef8cb2c4cf
commit b394f81477
5 changed files with 46 additions and 7 deletions

View File

@@ -32,14 +32,14 @@ const state = {
setInPatch(i: number, sprsheet: number, sprite: number) {
const xx = this.selectedPatch%overviewW;
const yy = Math.floor(this.selectedPatch/overviewW);
const cell = (yy+patchH*Math.floor(i/patchW))*overviewW*patchW+xx*patchW+i%patchW;
const cell = (yy*patchH+Math.floor(i/patchW))*overviewW*patchW+xx*patchW+i%patchW;
this.map[cell] = [sprsheet, sprite];
},
get patch() {
const xx = this.selectedPatch%overviewW;
const yy = Math.floor(this.selectedPatch/overviewW);
return Array(overviewH).fill(0).flatMap((_, i) => {
const start = (yy+patchH*i)*overviewW*patchW+xx*patchW;
const start = (yy*patchH+i)*overviewW*patchW+xx*patchW;
return this.map.slice(start, start+patchW);
})
}