Giter Site home page Giter Site logo

smivan / pixi-tilemap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pixijs/tilemap

0.0 1.0 0.0 18.46 MB

Library that will help with tilemaps, provide special shaders and canvas fallback. Rpgmaker support - check. Tiled, gameofbombs - in progress.

License: MIT License

CSS 66.92% HTML 1.65% TypeScript 31.42%

pixi-tilemap's Introduction

pixi-tilemap

Build Status

Library that helps with tilemaps, provide special shaders and canvas fallback. Works with pixi >= 5.0.4

Type of builds (Important!)

Beware, we've changed the filename of good old ES5 build, according to pixi-build-tools rollup config!

<script src="dist/pixi-tilemap.umd.js"></script>

CommonJS build is located in dist/pixi-tilemap.js.

ESM is specified in package.json.

Multi-texture Configuration (Important!) ๐Ÿ“„

Please specify how many base textures do you want to use. That's the default:

PIXI.tilemap.Constant.maxTextures = 4;

That means, if you use 5th baseTexture, compositeRectTileLayer will move it to second RectTileLayer and all tiles of that texture will go on different Z level!

Specify bigger maxTextures if you want everything to be on the same Z.

PIXI.tilemap.Constant.maxTextures = 16;

Not every device does have 16 texture locations, so, its possible to fit 4 textures of 1024 into 1 of 2048, that's why boundCountPerBuffer exists. In that case, if you render the tilemap with other textures, textures will be re-uploaded - that can slow down things due to extra subTexImage2D in frame.

This is old RpgMakerMV-compatible setting:

PIXI.tilemap.Constant.boundCountPerBuffer = 4;
PIXI.tilemap.Constant.maxTextures = 4;

Or you can just set maxTextures to 16 and forget about old devices and texImage2D slowdown.

There's also a limitation on 16k tiles per one tilemap. If you want to lift it, please use pixi v5.1.0 and following setting:

PIXI.tilemap.Constant.use32bitIndex = true;

For RPGMaker MV please use v4 branch for pixi V4, npm version is 1.2.6

Please use v3 branch for pixi V3.

Canvas fallback is 5x slower than vanilla rpgmaker. Webgl version is faster and doesnt use extra textures.

RPGMaker demo

webgl: zoomin and zoomout

retina webgl: zoomin and zoomout

canvas

Basic demo ๐Ÿ–Š๏ธ

webgl

<script src="https://github.com/pixijs/pixi-tilemap/blob/master/src/pixi-tilemap.js"></script>
var renderer = PIXI.autoDetectRenderer(800, 600);
document.body.appendChild(renderer.view);

var loader = new PIXI.loaders.Loader();
loader.add('atlas', 'basic/atlas.json');
loader.load(function(loader, resources) {
	var tilemap = new PIXI.tilemap.CompositeRectTileLayer(0, [resources['atlas_image'].texture]);
    var size = 32;
    // bah, im too lazy, i just want to specify filenames from atlas
    for (var i=0;i<7;i++)
        for (var j=0;j<7;j++) {
            tilemap.addFrame("grass.png", i*size, j*size);
            if (i%2==1 && j%2==1)
                tilemap.addFrame("tough.png", i*size, j*size);
        }

    // if you are lawful citizen, please use textures from the loader
    var textures = resources.atlas.textures;
    tilemap.addFrame(textures["brick.png"], 2*size, 2*size);
    tilemap.addFrame(textures["brick_wall.png"], 2*size, 3*size);

    renderer.render(tilemap);
});

More tutorials ๐Ÿ”—

Alan01252 tutorial

pixi-tilemap's People

Contributors

ivanpopelyshev avatar shukantpal avatar finscn avatar exponenta avatar dependabot[bot] avatar alan01252 avatar megabyteceer avatar pixelpicosean avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.