∅:D[
9.641] → [
5.1148:1247]
B:BD[
4.655] → [
5.1148:1247]
B:BD[
5.1247] → [
9.642:695]
∅:D[
9.695] → [
5.1285:1292]
B:BD[
5.1285] → [
5.1285:1292]
B:BD[
5.1292] → [
7.61:160]
B:BD[
5.1292] → [
10.0:314]
∅:D[
10.314] → [
5.1292:1336]
B:BD[
5.1292] → [
5.1292:1336]
∅:D[
5.1336] → [
4.703:881]
B:BD[
4.703] → [
4.703:881]
B:BD[
4.881] → [
5.1337:1553]
B:BD[
5.1553] → [
9.696:755]
∅:D[
9.755] → [
5.1594:1603]
B:BD[
5.1594] → [
5.1594:1603]
B:BD[
5.1603] → [
11.0:106]
B:BD[
11.106] → [
7.161:162]
∅:D[
7.162] → [
5.1632:1669]
∅:D[
11.106] → [
5.1632:1669]
B:BD[
5.1632] → [
5.1632:1669]
B:BD[
5.1669] → [
11.107:192]
∅:D[
11.192] → [
5.1737:1772]
B:BD[
5.1737] → [
5.1737:1772]
B:BD[
5.1772] → [
11.193:299]
∅:D[
11.299] → [
5.1772:1780]
B:BD[
5.1772] → [
5.1772:1780]
B:BD[
5.2219] → [
5.2219:2537]
B:BD[
5.2537] → [
11.300:427]
∅:D[
11.427] → [
5.2537:2594]
B:BD[
5.2537] → [
5.2537:2594]
B:BD[
5.2594] → [
11.428:457]
B:BD[
11.457] → [
7.163:425]
∅:D[
7.425] → [
11.457:498]
B:BD[
11.457] → [
11.457:498]
B:BD[
11.498] → [
7.426:470]
B:BD[
11.562] → [
9.756:825]
∅:D[
9.825] → [
11.608:805]
B:BD[
11.608] → [
11.608:805]
B:BD[
11.805] → [
9.826:901]
∅:D[
9.901] → [
11.854:1147]
B:BD[
11.854] → [
11.854:1147]
∅:D[
11.1147] → [
5.3159:3169]
B:BD[
5.3159] → [
5.3159:3169]
∅:D[
12.2147] → [
4.1194:1202]
∅:D[
5.3169] → [
4.1194:1202]
B:BD[
4.1194] → [
4.1194:1202]
B:BD[
4.1202] → [
5.3170:3491]
B:BD[
5.3491] → [
11.1148:1275]
∅:D[
11.1275] → [
5.3491:3548]
B:BD[
5.3491] → [
5.3491:3548]
B:BD[
5.3548] → [
11.1276:1305]
B:BD[
11.1305] → [
7.471:733]
∅:D[
7.733] → [
11.1305:1346]
B:BD[
11.1305] → [
11.1305:1346]
B:BD[
11.1346] → [
7.734:778]
B:BD[
11.1410] → [
9.902:971]
∅:D[
9.971] → [
11.1456:1653]
B:BD[
11.1456] → [
11.1456:1653]
B:BD[
11.1653] → [
9.972:1047]
∅:D[
9.1047] → [
11.1702:1995]
B:BD[
11.1702] → [
11.1702:1995]
∅:D[
11.1995] → [
5.4156:4182]
B:BD[
5.4156] → [
5.4156:4182]
// create the world
let zLevel = new RenderedZLevel(
new ZLevel(this.randomSeed, 0),
this.config.onFocusedNodeChange,
texture
);
let zLevelPersistence: { [i: number]: ZLevel } = {};
zLevelPersistence[0] = zLevel.zLevel;
// find the 0th square, and allocate it
for (let chunk of zLevel.zLevel.chunks) {
if (chunk.location.x === 0 && chunk.location.y === 0) {
chunk.allocatedNodes.put(new Vector2(0, 0));
zLevel.renderedChunks.get(chunk).renderedNodes.get(new Vector2(0, 0)).tint = 0x00AAFF;
}
}
let chunksContainer = zLevel.container;
this.actionStage.addChild(chunksContainer);
chunksContainer.x = this.app.screen.width/2;
chunksContainer.y = this.app.screen.height/2;
this.onResize.push(() => {
chunksContainer.x = this.app.screen.width / 2;
chunksContainer.y = this.app.screen.height / 2;
});
// let preloadedZLevelDown = new RenderedZLevel(
// new ZLevel(this.randomSeed, -1),
// this.config.onFocusedNodeChange,
// texture
// )
let chunkOriginalWidth = chunksContainer.width;
let chunkOriginalHeight = chunksContainer.height;
this.app.ticker.add((delta) => {
if (this.keyboard.justUp[">"] || this.keyboard.justUp["<"]) {
// reset
chunksContainer.alpha = 1;
chunksContainer.width = chunkOriginalWidth;
chunksContainer.height = chunkOriginalHeight;
}
if (this.keyboard.down[">"]) {
// phase out the current z level and go to another one
chunksContainer.alpha -= 0.1;
chunksContainer.width *= 1.03;
chunksContainer.height *= 1.03;
// this.actionStage.removeChild(chunksContainer);
if (chunksContainer.alpha <= 0) {
chunksContainer.alpha = 1;
// start the process to render next z level
backdrop.tint = 0xDDAADD;
this.actionStage.removeChild(chunksContainer);
setTimeout(() => {
let newZIndex = zLevel.zLevel.z - 1;
// prefer cached persistence data if it is available
if (!zLevelPersistence[newZIndex]) {
zLevelPersistence[newZIndex] = new ZLevel(this.randomSeed, newZIndex);
}
zLevel = new RenderedZLevel(
zLevelPersistence[newZIndex],
this.config.onFocusedNodeChange,
texture
);
// zLevel = preloadedZLevelDown;
// preloadedZLevelDown = new RenderedZLevel(
// new ZLevel(this.randomSeed, preloadedZLevelDown.zLevel.z - 1),
// this.config.onFocusedNodeChange,
// texture
// );
chunksContainer = zLevel.container;
this.actionStage.addChild(chunksContainer);
chunksContainer.x = this.app.screen.width / 2;
chunksContainer.y = this.app.screen.height / 2;
backdrop.tint = 0xFFFFFF;
});
}
}
if (this.keyboard.down["<"]) {
// phase out the current z level and go to another one
chunksContainer.alpha -= 0.1;
chunksContainer.width *= 1/1.03;
chunksContainer.height *= 1/1.03;
// this.actionStage.removeChild(chunksContainer);
if (chunksContainer.alpha <= 0) {
// start the process to render next z level
chunksContainer.alpha = 1;
backdrop.tint = 0xDDAADD;
this.actionStage.removeChild(chunksContainer);
setTimeout(() => {
let newZIndex = zLevel.zLevel.z + 1;
// prefer cached persistence data if it is available
if (!zLevelPersistence[newZIndex]) {
zLevelPersistence[newZIndex] = new ZLevel(this.randomSeed, newZIndex);
}
zLevel = new RenderedZLevel(
zLevelPersistence[newZIndex],
this.config.onFocusedNodeChange,
texture
);
// zLevel = preloadedZLevelDown;
// preloadedZLevelDown = new RenderedZLevel(
// new ZLevel(this.randomSeed, preloadedZLevelDown.zLevel.z - 1),
// this.config.onFocusedNodeChange,
// texture
// );
chunksContainer = zLevel.container;
this.actionStage.addChild(chunksContainer);
chunksContainer.x = this.app.screen.width / 2;
chunksContainer.y = this.app.screen.height / 2;
backdrop.tint = 0xFFFFFF;
});
}
}
});
// // create the world
// let zLevel = new RenderedZLevel(
// new ZLevel(this.randomSeed, 0),
// this.config.onFocusedNodeChange,
// texture
// );
// let zLevelPersistence: { [i: number]: ZLevel } = {};
// zLevelPersistence[0] = zLevel.zLevel;
// // find the 0th square, and allocate it
// for (let chunk of zLevel.zLevel.chunks) {
// if (chunk.location.x === 0 && chunk.location.y === 0) {
// chunk.allocatedNodes.put(new Vector2(0, 0));
// zLevel.renderedChunks.get(chunk).renderedNodes.get(new Vector2(0, 0)).tint = 0x00AAFF;
// }
// }
// let chunksContainer = zLevel.container;
// this.actionStage.addChild(chunksContainer);
// chunksContainer.x = this.app.screen.width/2;
// chunksContainer.y = this.app.screen.height/2;
// this.onResize.push(() => {
// chunksContainer.x = this.app.screen.width / 2;
// chunksContainer.y = this.app.screen.height / 2;
// });
//
//
// // let preloadedZLevelDown = new RenderedZLevel(
// // new ZLevel(this.randomSeed, -1),
// // this.config.onFocusedNodeChange,
// // texture
// // )
// let chunkOriginalWidth = chunksContainer.width;
// let chunkOriginalHeight = chunksContainer.height;
//
// this.app.ticker.add((delta) => {
// if (this.keyboard.justUp[">"] || this.keyboard.justUp["<"]) {
// // reset
// chunksContainer.alpha = 1;
// chunksContainer.width = chunkOriginalWidth;
// chunksContainer.height = chunkOriginalHeight;
// }
//
// if (this.keyboard.down[">"]) {
// // phase out the current z level and go to another one
// chunksContainer.alpha -= 0.1;
// chunksContainer.width *= 1.03;
// chunksContainer.height *= 1.03;
// // this.actionStage.removeChild(chunksContainer);
// if (chunksContainer.alpha <= 0) {
// chunksContainer.alpha = 1;
// // start the process to render next z level
// backdrop.tint = 0xDDAADD;
// this.actionStage.removeChild(chunksContainer);
// setTimeout(() => {
// let newZIndex = zLevel.zLevel.z - 1;
// // prefer cached persistence data if it is available
// if (!zLevelPersistence[newZIndex]) {
// zLevelPersistence[newZIndex] = new ZLevel(this.randomSeed, newZIndex);
// }
// zLevel = new RenderedZLevel(
// zLevelPersistence[newZIndex],
// this.config.onFocusedNodeChange,
// texture
// );
// // zLevel = preloadedZLevelDown;
// // preloadedZLevelDown = new RenderedZLevel(
// // new ZLevel(this.randomSeed, preloadedZLevelDown.zLevel.z - 1),
// // this.config.onFocusedNodeChange,
// // texture
// // );
// chunksContainer = zLevel.container;
// this.actionStage.addChild(chunksContainer);
// chunksContainer.x = this.app.screen.width / 2;
// chunksContainer.y = this.app.screen.height / 2;
// backdrop.tint = 0xFFFFFF;
// });
// }
// }
// if (this.keyboard.down["<"]) {
// // phase out the current z level and go to another one
// chunksContainer.alpha -= 0.1;
// chunksContainer.width *= 1/1.03;
// chunksContainer.height *= 1/1.03;
// // this.actionStage.removeChild(chunksContainer);
// if (chunksContainer.alpha <= 0) {
// // start the process to render next z level
// chunksContainer.alpha = 1;
// backdrop.tint = 0xDDAADD;
// this.actionStage.removeChild(chunksContainer);
// setTimeout(() => {
// let newZIndex = zLevel.zLevel.z + 1;
// // prefer cached persistence data if it is available
// if (!zLevelPersistence[newZIndex]) {
// zLevelPersistence[newZIndex] = new ZLevel(this.randomSeed, newZIndex);
// }
// zLevel = new RenderedZLevel(
// zLevelPersistence[newZIndex],
// this.config.onFocusedNodeChange,
// texture
// );
// // zLevel = preloadedZLevelDown;
// // preloadedZLevelDown = new RenderedZLevel(
// // new ZLevel(this.randomSeed, preloadedZLevelDown.zLevel.z - 1),
// // this.config.onFocusedNodeChange,
// // texture
// // );
// chunksContainer = zLevel.container;
// this.actionStage.addChild(chunksContainer);
// chunksContainer.x = this.app.screen.width / 2;
// chunksContainer.y = this.app.screen.height / 2;
// backdrop.tint = 0xFFFFFF;
// });
// }
// }
// });