Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. addTile: function(x, y){
  2.         var tile = this.platforms.getFirstDead();
  3.  
  4.         tile.reset(x, y);
  5.         tile.body.velocity.y = 150;
  6.         tile.body.immovable = true;
  7.  
  8.         tile.checkWorldBounds = true;
  9.         tile.outOfBoundsKill = true;   
  10.     },
  11.  
  12.     addPlatform: function(y){
  13.         if(typeof(y) == "undefined"){
  14.             y = -this.tileHeight;
  15.             this.incrementScore();
  16.         }
  17.  
  18.         var tilesNeeded = Math.ceil(this.game.world.width / this.tileWidth);
  19.  
  20.         var hole = Math.floor(Math.random() * (tilesNeeded - 3)) + 1;
  21.  
  22.         for (var i = 0; i < tilesNeeded; i++){
  23.             if (i != hole && i != hole + 1){
  24.                 this.addTile(i * this.tileWidth, y);
  25.             }          
  26.         }
  27.     },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement