sync
This commit is contained in:
parent
26ba098183
commit
2f7bcbb14e
30 changed files with 1691 additions and 315 deletions
|
@ -1,18 +1,29 @@
|
|||
import { Pixmap } from "./haku.js";
|
||||
import { OnlineUsers } from "./online-users.js";
|
||||
|
||||
export class Chunk {
|
||||
constructor(size) {
|
||||
this.pixmap = new Pixmap(size, size);
|
||||
this.canvas = new OffscreenCanvas(size, size);
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
}
|
||||
|
||||
syncFromPixmap() {
|
||||
this.ctx.putImageData(this.pixmap.imageData, 0, 0);
|
||||
}
|
||||
|
||||
syncToPixmap() {
|
||||
let imageData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
|
||||
this.pixmap.imageData.data.set(imageData.data, 0);
|
||||
}
|
||||
}
|
||||
|
||||
export class Wall {
|
||||
#chunks = new Map();
|
||||
onlineUsers = new OnlineUsers();
|
||||
|
||||
constructor(chunkSize) {
|
||||
this.chunkSize = chunkSize;
|
||||
constructor(wallInfo) {
|
||||
this.chunkSize = wallInfo.chunkSize;
|
||||
this.onlineUsers = new OnlineUsers(wallInfo);
|
||||
}
|
||||
|
||||
static chunkKey(x, y) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue