From ee966f4331418f6ae44a2604de2b10c1d188417d Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 28 Jun 2021 11:53:58 +0200 Subject: [PATCH] Rename PixelManipulator to Schematic --- engine/init.js | 2 +- engine/mapgen.js | 34 +++++++++---------- engine/{pixel_manipulator.js => schematic.js} | 16 ++++----- game/plants/plants.js | 10 +++--- game/tnt/init.js | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) rename engine/{pixel_manipulator.js => schematic.js} (90%) diff --git a/engine/init.js b/engine/init.js index 0f76fb1..349d467 100644 --- a/engine/init.js +++ b/engine/init.js @@ -203,7 +203,7 @@ "falling_node", "timer", "player", - "pixel_manipulator", + "schematic", "chat", "chatcommands", "mainmenu", diff --git a/engine/mapgen.js b/engine/mapgen.js index 8aeba2d..b1c6e13 100644 --- a/engine/mapgen.js +++ b/engine/mapgen.js @@ -59,7 +59,7 @@ dragonblocks.mapgen.list["v3"] = _ => { let snode = dragonblocks.setNode; let gnode = dragonblocks.getNode; - let pm = dragonblocks.PixelManipulator; + let schem = dragonblocks.Schematic; let rand = dblib.random; @@ -337,35 +337,35 @@ dragonblocks.mapgen.list["v3"] = _ => { }; function structure(x, y, mat) { - new pm([["§" + mat, mat], [mat, mat]]) + new schem([["§" + mat, mat], [mat, mat]]) .addFunction(belowGround) .apply(x, y); let sides = [ - new pm([[mat, mat], ["§", ""]]), - new pm([["§", "", mat], ["", "", mat]]), - new pm([["§", ""], ["", ""], [mat, mat]]), - new pm([[mat, "§"], [mat, ""]]), + new schem([[mat, mat], ["§", ""]]), + new schem([["§", "", mat], ["", "", mat]]), + new schem([["§", ""], ["", ""], [mat, mat]]), + new schem([[mat, "§"], [mat, ""]]), ]; for (let side of sides) side.addFunction(belowGround); let moresides = [ - new pm([[mat, mat], ["", ""], ["§", ""]]), - new pm([["§", "", "", mat], ["", "", "", mat]]), - new pm([["§", ""], ["", ""], ["", ""], [mat, mat]]), - new pm([[mat, "", "§"], [mat, "", ""]]), + new schem([[mat, mat], ["", ""], ["§", ""]]), + new schem([["§", "", "", mat], ["", "", "", mat]]), + new schem([["§", ""], ["", ""], ["", ""], [mat, mat]]), + new schem([[mat, "", "§"], [mat, "", ""]]), ]; for (let moreside of moresides) moreside.addFunction(belowGround); let corners = [ - new pm([[mat, ""], ["", "§"]]), - new pm([["", "", mat], ["§", "", ""]]), - new pm([["§", "", ""], ["", "", ""], ["", "", mat]]), - new pm([["§", "", ""], ["", "", ""], ["", "", mat]]), + new schem([[mat, ""], ["", "§"]]), + new schem([["", "", mat], ["§", "", ""]]), + new schem([["§", "", ""], ["", "", ""], ["", "", mat]]), + new schem([["§", "", ""], ["", "", ""], ["", "", mat]]), ]; for (let corner of corners) @@ -399,7 +399,7 @@ dragonblocks.mapgen.list["v3"] = _ => { let cave = (x, y, r) => { r *= 2; - let cavepm = new pm([ + let caveschem = new schem([ ["", "air", "air", "air", ""], ["air", "air", "air", "air", "air"], ["air", "air", "§air", "air", "air"], @@ -407,7 +407,7 @@ dragonblocks.mapgen.list["v3"] = _ => { ["", "air", "air", "air", ""], ]); - cavepm.addFunction((node, x, y) => { + caveschem.addFunction((node, x, y) => { if (y < ground[x]) return false; @@ -415,7 +415,7 @@ dragonblocks.mapgen.list["v3"] = _ => { cave(x, y, r); }); - cavepm.apply(x, y); + caveschem.apply(x, y); }; let newCave = (x, y) => { diff --git a/engine/pixel_manipulator.js b/engine/schematic.js similarity index 90% rename from engine/pixel_manipulator.js rename to engine/schematic.js index 31a0d31..ba893f9 100644 --- a/engine/pixel_manipulator.js +++ b/engine/schematic.js @@ -1,5 +1,5 @@ /* - * pixel_manipulator.js + * schematic.js * * Copyright 2020 Elias Fleckenstein * @@ -21,21 +21,21 @@ * */ -dragonblocks.PixelManipulator = class +dragonblocks.Schematic = class { constructor(arr) { this.data = []; this.functions = []; - let pos; + let anchor; for (let y = 0; y < arr.length; y++) { for (let x = 0; x < arr[y].length; x++) { let node = arr[y][x]; if (node[0] == "§") { - pos = {x: x, y: y}; + anchor = {x: x, y: y}; node = node.slice(1, node.length); } @@ -50,12 +50,12 @@ dragonblocks.PixelManipulator = class } } - if (! pos) - pos = {x: 0, y: 0}; + if (! anchor) + anchor = {x: 0, y: 0}; for (let pixel of this.data) { - pixel.x = pixel.x - pos.x; - pixel.y = pixel.y - pos.y; + pixel.x = pixel.x - anchor.x; + pixel.y = pixel.y - anchor.y; } } diff --git a/game/plants/plants.js b/game/plants/plants.js index d62a33f..767e564 100644 --- a/game/plants/plants.js +++ b/game/plants/plants.js @@ -24,7 +24,7 @@ doors.registerDoor({ }); plants.registerTree({ name: "apple", - tree: new dragonblocks.PixelManipulator([ + tree: new dragonblocks.Schematic([ ["leaves", "leaves", "leaves"], ["leaves", "leaves", "leaves"], ["leaves", "leaves", "leaves"], @@ -38,7 +38,7 @@ plants.registerTree({ }); plants.registerTree({ name: "pine", - tree: new dragonblocks.PixelManipulator([ + tree: new dragonblocks.Schematic([ ["", "", "leaves", "", ""], ["", "", "leaves", "", ""], ["", "leaves", "leaves", "leaves", ""], @@ -56,7 +56,7 @@ plants.registerTree({ }); plants.registerTree({ name: "acacia", - tree: new dragonblocks.PixelManipulator([ + tree: new dragonblocks.Schematic([ ["", "", "leaves", "leaves", "leaves", "", ""], ["leaves", "leaves", "leaves", "tree", "leaves", "leaves", "leaves"], ["leaves", "tree", "leaves", "tree", "leaves", "tree", "leaves"], @@ -71,7 +71,7 @@ plants.registerTree({ }); plants.registerTree({ name: "jungle", - tree: new dragonblocks.PixelManipulator([ + tree: new dragonblocks.Schematic([ ["", "leaves", "leaves", "leaves", ""], ["leaves", "leaves", "leaves", "leaves", "leaves"], ["leaves", "leaves", "leaves", "leaves", "leaves"], @@ -94,7 +94,7 @@ plants.registerTree({ }); plants.registerTree({ name: "aspen", - tree: new dragonblocks.PixelManipulator([ + tree: new dragonblocks.Schematic([ ["leaves", "leaves", "leaves"], ["leaves", "leaves", "leaves"], ["leaves", "leaves", "leaves"], diff --git a/game/tnt/init.js b/game/tnt/init.js index 3cf0031..720af3d 100644 --- a/game/tnt/init.js +++ b/game/tnt/init.js @@ -1,5 +1,5 @@ tnt = {}; -tnt.explosion = new dragonblocks.PixelManipulator([ +tnt.explosion = new dragonblocks.Schematic([ ["", "air", "air", "air", ""], ["air", "air", "air", "air", "air"], ["air", "air", "§air", "air", "air"], -- 2.44.0