summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-10-31 21:55:41 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-10-31 21:55:41 +0100
commit1f9cd7a110e4fe1cf3b4eb220a083fa0f9b0cf98 (patch)
tree49e75c0cd3f3da715697106ab20e7d7f51bb9a61
parent31c131289c6b37a08ea66e988eaded1cd9c9c72c (diff)
downloadrpgedit-1f9cd7a110e4fe1cf3b4eb220a083fa0f9b0cf98.tar
rpgedit-1f9cd7a110e4fe1cf3b4eb220a083fa0f9b0cf98.zip
Switch from characters to numerical tile IDs
-rw-r--r--dist/resources/map/test.json202
-rw-r--r--src/model/data/MapData.ts14
-rw-r--r--src/view/map.ts43
-rw-r--r--src/view/util/image.ts6
4 files changed, 128 insertions, 137 deletions
diff --git a/dist/resources/map/test.json b/dist/resources/map/test.json
index 7044751..7d6287e 100644
--- a/dist/resources/map/test.json
+++ b/dist/resources/map/test.json
@@ -1,111 +1,111 @@
{
- "tiles": {
- "G": "grass",
- "<": "road_left",
- ">": "road_right"
- },
+ "tiles": [
+ "grass",
+ "road_left",
+ "road_right"
+ ],
"collision": [
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000000000000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000",
- "00000001100000000000000000000000"
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
+ [false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
],
"layers": [
[
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
- "GGGGGGGGGGGGGGGGGGGGGGGGGG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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
],
[
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> ",
- " <> "
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]
]
}
diff --git a/src/model/data/MapData.ts b/src/model/data/MapData.ts
index 0f14f50..0c44d94 100644
--- a/src/model/data/MapData.ts
+++ b/src/model/data/MapData.ts
@@ -1,21 +1,21 @@
import {mapFromObject} from '../../util';
interface Input {
- readonly tiles: {[key: string]: string};
- readonly collision: string[];
- readonly layers: string[][][];
+ readonly tiles: string[];
+ readonly collision: boolean[][];
+ readonly layers: number[][][];
}
export default class MapData {
- public readonly tiles: Map<string, string>;
- public readonly collision: string[];
- public readonly layers: string[][][];
+ public readonly tiles: string[];
+ public readonly collision: boolean[][];
+ public readonly layers: number[][][];
public readonly width: number;
public readonly height: number;
constructor(data: Input) {
- this.tiles = mapFromObject(data.tiles);
+ this.tiles = data.tiles;
this.collision = data.collision;
this.layers = data.layers;
diff --git a/src/view/map.ts b/src/view/map.ts
index d75ea98..d7c9ce9 100644
--- a/src/view/map.ts
+++ b/src/view/map.ts
@@ -1,38 +1,38 @@
import MapData from '../model/data/MapData';
-import { mapValues, nextPowerOf2 } from '../util';
+import { nextPowerOf2 } from '../util';
import Renderer from './renderer/Renderer';
import { SpriteCoords, SpriteView, SpriteViewBuilder } from './sprite';
-import { loadImages, mkTexture } from './util/image';
+import { loadImage, mkTexture } from './util/image';
-interface TileMap {
+interface Tileset {
texture: WebGLTexture;
- tiles: Map<string, SpriteCoords>;
+ tiles: SpriteCoords[];
}
-function loadTiles(tiles: Map<string, string>): Promise<Map<string, HTMLImageElement>> {
- return loadImages(mapValues((t) => `resources/sprite/tile/${t}.png`, tiles));
+function loadTiles(tiles: string[]): Promise<HTMLImageElement[]> {
+ return Promise.all(tiles.map((t) => loadImage(`resources/sprite/tile/${t}.png`)));
}
-function mkTileMap(
+function mkTileset(
gl: WebGLRenderingContext,
- tiles: Map<string, HTMLImageElement>,
-): TileMap {
+ tiles: HTMLImageElement[],
+): Tileset {
const tileSize = 32;
- const canvasDim = nextPowerOf2(Math.sqrt(tiles.size));
+ const canvasDim = nextPowerOf2(Math.sqrt(tiles.length));
const canvasSize = canvasDim * tileSize;
const canvas = document.createElement('canvas');
canvas.width = canvas.height = canvasSize;
let x = 0, y = 0;
- const map: Map<string, SpriteCoords> = new Map();
+ const tileCoords: SpriteCoords[] = [];
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
- for (const [k, tile] of tiles) {
+ for (const tile of tiles) {
ctx.drawImage(tile, x * tileSize, y * tileSize);
- map.set(k, [x / canvasDim, y / canvasDim, (x + 1) / canvasDim, (y + 1) / canvasDim]);
+ tileCoords.push([x / canvasDim, y / canvasDim, (x + 1) / canvasDim, (y + 1) / canvasDim]);
x++;
if (x === canvasDim) {
@@ -43,31 +43,28 @@ function mkTileMap(
return {
texture: mkTexture(gl, canvas),
- tiles: map,
+ tiles: tileCoords,
};
}
-function addSprite(builder: SpriteViewBuilder, tileMap: TileMap, x: number, y: number, tile: string) {
- if (tile === ' ')
+function addSprite(builder: SpriteViewBuilder, tileset: Tileset, x: number, y: number, tile: number) {
+ if (tile === 0)
return;
- const tilePos = tileMap.tiles.get(tile);
- if (!tilePos)
- throw new Error('invalid tile specifier in map data');
-
+ const tilePos = tileset.tiles[tile - 1];
builder.addSprite([x, y, x + 1, y + 1], tilePos);
}
export async function loadMap(r: Renderer, map: MapData): Promise<SpriteView> {
const tiles = await loadTiles(map.tiles);
- const tileMap = mkTileMap(r.getContext(), tiles);
+ const tileset = mkTileset(r.getContext(), tiles);
- const builder = new SpriteViewBuilder(r, tileMap.texture);
+ const builder = new SpriteViewBuilder(r, tileset.texture);
for (const layer of map.layers)
for (let x = 0; x < map.width; x++)
for (let y = 0; y < map.height; y++)
- addSprite(builder, tileMap, x, y, layer[y][x]);
+ addSprite(builder, tileset, x, y, layer[y][x]);
return builder.build();
}
diff --git a/src/view/util/image.ts b/src/view/util/image.ts
index 50debde..73edbba 100644
--- a/src/view/util/image.ts
+++ b/src/view/util/image.ts
@@ -1,5 +1,3 @@
-import { mapValuesAsync } from '../../util';
-
export function loadImage(url: string): Promise<HTMLImageElement> {
return new Promise((resolve, reject) => {
const img = new Image();
@@ -9,10 +7,6 @@ export function loadImage(url: string): Promise<HTMLImageElement> {
});
}
-export function loadImages(urls: Map<string, string>): Promise<Map<string, HTMLImageElement>> {
- return mapValuesAsync(loadImage, urls);
-}
-
export function mkTexture(gl: WebGLRenderingContext, src: HTMLCanvasElement|HTMLImageElement): WebGLTexture {
const texture = gl.createTexture();
if (!texture)