Search This Blog

Wednesday, April 13, 2016

Map editor is progressing

The map editor of my hobby project is progressing. Beside having finally plants and trees placed on the grass by the world generator, the map editor has by default a grid display to make it a bit easier to see where the tiles are. You can disable it if needed.

Also I worked on the first "functions" of the map editor which now let you choose either by painting tiles or placing / removing objects.



To make sure the render engine is not slowed down by searching the objects to render, a grid cache has been implemented which means objects are placed in a grid of the same size of tiles.

The drawback of such optimization means each time you change the objects or change the position of an object you will need to update the grid cache.

To make the look more natural objects are not placed on a grid either, they are freely to be placed anywhere you want on the map.

Finally, to make my life easier to deal with the JSON art definition I improved the typescript interface which let me directly access from within Typescript the the JSON:

interface TilesetInformation
{
    background: TilesetMap;
    objects: TilesetObject;
}
interface TilesetMap
{
    file: string;
    width: number;
    height: number;
    types: TilesetType;
    mainType: string;
    transitions?: TilesetTransition[];
    levels?: TilesetLevels[];
}
interface TilesetType
{
    [s: string]: number[];
}
interface TilesetTransition
{
    fromstring;
    to: string;
    transition: number[];
}
interface TilesetLevels
{
    typestring;
    maxLevel: number;
}
interface TilesetObject
{
    [s: string]: TilsetObjectDetails;
}
interface TilsetObjectDetails
{
    file: string;
    width: number;
    height: number;
    groundX?: number;
    groundY?: number;
    x: number;
    y: number;
    frequency?: number;
    placeOn?: string[];
}
Having a well defined JSON file ensures I don't mess around while trying to access information.

No comments:

Post a Comment