render = {
const world = newWorld();
const width = world.cellSize * world.width;
const height = world.cellSize * world.height;
const app = new PIXI.Application({
width: width,
height: height,
antialias: false,
resolution: 1,
forceCanvas: false
});
var stage = new PIXI.Stage(0xFFFFFF);
var textureCtx = DOM.context2d(width,height);
for (var i=0; i<world.palette.length; i++) {
textureCtx.fillStyle = 'rgba(' + world.palette[i] + ')';
textureCtx.fillRect(i*world.cellSize, 0, world.cellSize, world.cellSize);
}
var baseTexture = new PIXI.BaseTexture.fromCanvas(textureCtx.canvas);
var textures = [];
for (var i=0; i<world.palette.length; i++) {
textures.push(new PIXI.Texture(baseTexture, new PIXI.Rectangle(i*world.cellSize, 0, world.cellSize, world.cellSize)));
}
var pixels = [];
drawGrid(pixels,world,stage,textures);
while(true){
world.step();
updateGrid(pixels, world, textures);
app.renderer.render(stage);
yield app.view;
}
}