Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. export default class DungeonScene extends Phaser.Scene {
  2. // ... preload omitted for brevity
  3.  
  4. create() {
  5. // Generate a random world with a few extra options:
  6. // - Rooms should only have odd dimensions so that they have a center tile.
  7. // - Doors should be at least 2 tiles away from corners, to leave enough room for the tiles
  8. // that we're going to put on either side of the door opening.
  9. this.dungeon = new Dungeon({
  10. width: 50,
  11. height: 50,
  12. doorPadding: 2,
  13. rooms: {
  14. width: { min: 7, max: 15, onlyOdd: true },
  15. height: { min: 7, max: 15, onlyOdd: true }
  16. }
  17. });
  18.  
  19. // Creating a blank tilemap with dimensions matching the dungeon
  20. const map = this.make.tilemap({
  21. tileWidth: 48,
  22. tileHeight: 48,
  23. width: this.dungeon.width,
  24. height: this.dungeon.height
  25. });
  26. const tileset = map.addTilesetImage("tiles", null, 48, 48, 1, 2); // 1px margin, 2px spacing
  27. this.groundLayer = map.createBlankDynamicLayer("Ground", tileset); // Wall & floor
  28. this.stuffLayer = map.createBlankDynamicLayer("Stuff", tileset); // Chest, stairs, etc.
  29. }
  30. }
Add Comment
Please, Sign In to add comment