diff --git a/assets/ground6.svg b/assets/box.svg similarity index 100% rename from assets/ground6.svg rename to assets/box.svg diff --git a/assets/ground3.svg b/assets/collapseA.svg similarity index 100% rename from assets/ground3.svg rename to assets/collapseA.svg diff --git a/assets/ground4.svg b/assets/collapseB.svg similarity index 100% rename from assets/ground4.svg rename to assets/collapseB.svg diff --git a/assets/ground1.svg b/assets/groundA.svg similarity index 100% rename from assets/ground1.svg rename to assets/groundA.svg diff --git a/assets/ground2.svg b/assets/groundB.svg similarity index 100% rename from assets/ground2.svg rename to assets/groundB.svg diff --git a/assets/ground5.svg b/assets/nothing.svg similarity index 100% rename from assets/ground5.svg rename to assets/nothing.svg diff --git a/assets/player.svg b/assets/player.svg index e9a7e8e..df805b8 100644 --- a/assets/player.svg +++ b/assets/player.svg @@ -23,9 +23,9 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" - inkscape:zoom="0.066142459" - inkscape:cx="2509.7343" - inkscape:cy="3099.3707" + inkscape:zoom="0.13228492" + inkscape:cx="3171.1854" + inkscape:cy="2502.1749" inkscape:window-width="1860" inkscape:window-height="1004" inkscape:window-x="30" @@ -499,1393 +499,10 @@ inkscape:transform-center-x="1.352376e-06" inkscape:transform-center-y="-21.777159" transform="translate(524.82464,-832.62267)" /> diff --git a/js/index.js b/js/index.js index 7da2d4e..6ea5722 100644 --- a/js/index.js +++ b/js/index.js @@ -1,15 +1,15 @@ //const width = 2048; //const height = 2048; const tileSize = 128; -// todo: make names better +const chunkSize = 16; const assets = [ - 'assets/ground1.svg', - 'assets/ground2.svg', + 'assets/groundA.svg', + 'assets/groundB.svg', 'assets/player.svg', - 'assets/ground3.svg', - 'assets/ground4.svg', - 'assets/ground5.svg', - 'assets/ground6.svg' + 'assets/collapseA.svg', + 'assets/collapseB.svg', + 'assets/nothing.svg', + 'assets/box.svg' ]; function getRGBA(data, i) { @@ -50,8 +50,8 @@ function toPoint(x2, y2, base, fac, exp, inSize) { } function getChunk(x, y) { - let cx = Math.floor(x / 16); - let cy = Math.floor(y / 16); + let cx = Math.floor(x / chunkSize); + let cy = Math.floor(y / chunkSize); let id = cx + ',' + cy; @@ -80,14 +80,14 @@ Game.prototype.placeBlock = function (block) { let x = Math.round(camera[0] / tileSize); let y = Math.round(camera[1] / tileSize); - let bx = x % 16; - let by = y % 16; + let bx = x % chunkSize; + let by = y % chunkSize; let id = getChunk(x, y); - let chunk = this.modChunks[id] = this.modChunks[id] || new Uint8Array(16 * 16); + let chunk = this.modChunks[id] = this.modChunks[id] || new Uint8Array(chunkSize * chunkSize); - chunk[by * 16 + bx] = block + 1; + chunk[by * chunkSize + bx] = block + 1; } Game.prototype.player = function () { @@ -143,11 +143,11 @@ Game.prototype.main = function () { let chunk = this.modChunks[id]; - let bx = Math.round(x / tileSize) % 16; - let by = Math.round(y / tileSize)% 16; + let bx = Math.round(x / tileSize) % chunkSize; + let by = Math.round(y / tileSize)% chunkSize; - if (chunk && chunk[by * 16 + bx] != 0) { - ctx.drawImage(this.assets[chunk[by * 16 + bx] - 1], x2, y2, tileSize, tileSize); + if (chunk && chunk[by * chunkSize + bx] != 0) { + ctx.drawImage(this.assets[chunk[by * chunkSize + bx] - 1], x2, y2, tileSize, tileSize); continue; }