Santiago93 Posted January 17, 2017 Share Posted January 17, 2017 I wrote a function that makes rooms, corridors and walls of dungeons. There is 1 - as room and corridor and 2 - as wall. How can I set different tiles for 1 and 2? I was trying to make it with .addTileset, but somehow it sets the same image, but rotated. Link to comment Share on other sites More sharing options...
phreaknation Posted January 17, 2017 Share Posted January 17, 2017 I would suggest using tiled map editor and import it. would be your easiest way Link to comment Share on other sites More sharing options...
Santiago93 Posted January 17, 2017 Author Share Posted January 17, 2017 Actually the project is going to be rated on my ability of using VanillaJS, that's why I want to do it this way. Any idea? Link to comment Share on other sites More sharing options...
phreaknation Posted January 17, 2017 Share Posted January 17, 2017 Are you using Phaser.io? Link to comment Share on other sites More sharing options...
phreaknation Posted January 17, 2017 Share Posted January 17, 2017 Also can you give an example of your array? I wrote something a while back with just Pixi.js. If you are using phaser I would just use its importer, otherwise I can dig that code up for you soon Link to comment Share on other sites More sharing options...
Santiago93 Posted January 17, 2017 Author Share Posted January 17, 2017 [[2,2,2,2][2,1,1,2][2,1,1,2][2,2,2,2]] Later I put it .toString with '\ n', I just found it easier to write here Yes, I'm using Phaser .io Link to comment Share on other sites More sharing options...
Santiago93 Posted January 18, 2017 Author Share Posted January 18, 2017 Also, I'm interested in how to put collision into it Link to comment Share on other sites More sharing options...
phreaknation Posted January 18, 2017 Share Posted January 18, 2017 for (var y in map.data.floor) { var row = map.data.floor[y].split(','); for (var x in row) { var tile = row[x]; RPG.fn.draw.tile(tileset, tileTexture, 1, tile, x, y); } } render.tile = function (tileset, tileTexture, layerID, tile, x, y) { var a = tile.split(':')[0], b = tile.split(':')[1], tileProperties = tileset.regions[a], tileSprite = null, group_B = [ "default", "blank", "cross", "top_left", "top_center", "top_right", "middle_left", "middle_center", "middle_right", "bottom_left", "bottom_center", "bottom_right" ]; // Creat holder for tiles to reuse textures if (tileset.tiles === undefined) { tileset.tiles = {}; } // if tile is not present then creat tiles if (tileset.tiles[tileProperties.name] === undefined) { tile = RPG.fn.load.tile(tileset, tileTexture, tileProperties, group_B); } tileSprite = new PIXI.Sprite(tileset.tiles[tileProperties.name][group_B[b]]); tileSprite.scale.x = RPG.fn.config.scaleFactor; tileSprite.scale.y = RPG.fn.config.scaleFactor; RPG.fn.layers[layerID].addChild(tileSprite); tileSprite.position.x = RPG.fn.convert.GridToPixel(x) * RPG.fn.config.scaleFactor; tileSprite.position.y = RPG.fn.convert.GridToPixel(y) * RPG.fn.config.scaleFactor; }; Link to comment Share on other sites More sharing options...
phreaknation Posted January 18, 2017 Share Posted January 18, 2017 This in no means is a good way to do it and was written a couple years back. Link to comment Share on other sites More sharing options...
Santiago93 Posted January 18, 2017 Author Share Posted January 18, 2017 I just had to create own tileset out of two different images. My bad, now it works Thanks for your answers Link to comment Share on other sites More sharing options...
Recommended Posts