Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //These two functions spawn a psudo-random vertical set of blocks.
  2. //There are two kinds of blocks, one which the player can shoot to pass through
  3. //and "spike blocks" which can't be shot. The first function sets up two spans of breakable
  4. //blocks for the player to try to shoot, and the 2nd one spawns just one span of breakables
  5. //surrounded by spikes. Each column has exactly 14 blocks in them.
  6.  
  7.         public function setupBlocksBetter2():void
  8.         {
  9.             //spikeblock, then span of breakables, then 1 - 3 spikes, then breakables until the 2nd to last one, which is a spike
  10.             var rand:Number;
  11.             var i:int;
  12.             var blockcount:int = 1; //keep track of how many blocks we've spawned
  13.             i = 1;
  14.             _blocks.add(new block(Rsp, i * 15, globalSpeed)); //add top spike block
  15.             _spikeBlocks.add(new spikeblock(Rsp - 1, i * 15 + 3, globalSpeed));
  16.             blockcount ++;
  17.             rand = FlxU.random() * 6; //random number between 1 and 6
  18.             rand += 2; //add buffer in the event it's zero
  19.             for (i = 2; i <= rand; i++) //spwan those breakables
  20.             {
  21.                 _breakBlocks.add(new blockBreakable(Rsp, i * 15, _littleGibs, globalSpeed));
  22.                 blockcount ++;
  23.             }
  24.            
  25.             rand = FlxU.random() * 2;
  26.             rand += (blockcount + 1);
  27.             for (blockcount; blockcount <= rand; blockcount++)
  28.             {
  29.                 _blocks.add(new block(Rsp, blockcount * 15, globalSpeed));
  30.                 _spikeBlocks.add(new spikeblock(Rsp - 1, blockcount * 15 + 3, globalSpeed));
  31.             //  blockcount ++;
  32.             }
  33.            
  34.             for (blockcount; blockcount <= 13; blockcount++)
  35.             {
  36.                 _breakBlocks.add(new blockBreakable(Rsp, blockcount * 15, _littleGibs, globalSpeed));
  37.             }
  38.            
  39.             _blocks.add(new block(Rsp, 14 * 15, globalSpeed));
  40.             _spikeBlocks.add(new spikeblock(Rsp - 1, 14 * 15 + 3, globalSpeed));
  41.            
  42.         }
  43.        
  44.         public function setupBlocksBetter3():void
  45.         {
  46.             //instead of 2 spans of breakables, just one in the center
  47.            
  48.             var rand:Number;
  49.             var i:int;
  50.             var blockcount:int = 1; //keep track of how many blocks we've spawned
  51.             i = 1;
  52.             _blocks.add(new block(Rsp, i * 15, globalSpeed)); //add top spike block
  53.             _spikeBlocks.add(new spikeblock(Rsp - 1, i * 15 + 3, globalSpeed));
  54.             blockcount ++;
  55.             rand = FlxU.random() * 4; //random number between 1 and 4
  56.             rand += 1; //add buffer in the event it's zero
  57.             for (i = 2; i <= rand; i++) //spwan those spikes
  58.             {
  59.                 _blocks.add(new block(Rsp, blockcount * 15, globalSpeed));
  60.                 _spikeBlocks.add(new spikeblock(Rsp - 1, blockcount * 15 + 3, globalSpeed));
  61.                
  62.                 blockcount ++;
  63.             }
  64.            
  65.             rand = FlxU.random() * 6;
  66.             rand += (blockcount + 2);
  67.             for (blockcount; blockcount <= rand; blockcount++)
  68.             {
  69.                 _breakBlocks.add(new blockBreakable(Rsp, blockcount * 15, _littleGibs, globalSpeed));
  70.             //  blockcount ++;
  71.                 //middle section
  72.             }
  73.            
  74.            
  75.             for (blockcount; blockcount <= 13; blockcount++)
  76.             {
  77.                 _blocks.add(new block(Rsp, blockcount * 15, globalSpeed));
  78.                 _spikeBlocks.add(new spikeblock(Rsp - 1, blockcount * 15 + 3, globalSpeed));
  79.                 }
  80.              
  81.            
  82.             _blocks.add(new block(Rsp, 14 * 15, globalSpeed));
  83.             _spikeBlocks.add(new spikeblock(Rsp - 1, 14 * 15 + 3, globalSpeed));
  84.            
  85.            
  86.            
  87.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement