Guest User

Untitled

a guest
Mar 10th, 2013
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*********************************************************************8
  2.  * StationaryShip.js
  3.  * Small ship that helps the player and remains stationary
  4.  * @copyright (c) 2013 Dave Voyles, under The MIT License (see LICENSE)
  5.  *********************************************************************/
  6. ig.module(
  7.     'game.entities.StationaryShip'
  8. )
  9.     .requires(
  10.         'game.entities.player'
  11. )
  12.     .defines(function()
  13.     {
  14.         EntityStationaryShip = EntityPlayer.extend({
  15.         name: 'StationaryShip',
  16.         parental:null,
  17.         type:ig.Entity.TYPE.NONE,
  18.         checkAgainst: ig.Entity.TYPE.B, // Check Against B - our evil enemy group
  19.         collides: ig.Entity.COLLIDES.PASSIVE,
  20.         angle:0,
  21.         bCanSpawnShip: true,
  22.         bCanSpawnFirstShip: true,
  23.         increase:0,
  24.         totalWeapons: 4,
  25.         activeWeapon: "EntityBullet",
  26.         currentWeapLevel: 1,
  27.         maxWeapLevels: 2,
  28.  
  29.             /******************************************8
  30.              * Initialize
  31.              ******************************************/
  32.             init: function(x,y,settings){
  33.                this.parent( x, y, settings );
  34.  
  35.                this.bCanSpawnShips = true;
  36.                this.bCanSpawnFirstShip = true;
  37.  
  38.                // Used for constant fire
  39.                this.lastShootTimer = new ig.Timer(0);
  40.             },
  41.  
  42.             /******************************************8
  43.              * Update
  44.              ******************************************/
  45.             update:function(x,y,settings){
  46.  
  47.                 // Reference to player
  48.                 this.parental = ig.game.getEntitiesByType(EntityPlayer)[0];
  49.  
  50.                 // Spawning offset location of ships vs. player
  51.                 var offsetX = 20;
  52.                 var offsetY = 40;
  53.  
  54.  
  55.                 // Spawn ships when "X" button is hit
  56.                 if (this.bCanSpawnFirstShip){
  57.                     // Spawns above the player
  58.                     x = this.parental.pos. x + offsetX;
  59.                     y = this.parental.pos.y + offsetY;
  60.                     this.bCanSpawnFirstShip = false;
  61.                 }
  62.  
  63.  
  64.                  // else  (this.bCanSpawnSecondShip){
  65.                 else{
  66.                     // Spawns below player
  67.                     x = this.parental.pos.x + offsetX;
  68.                     y = this.parental.pos.y - offsetY;
  69.                     this.bCanSpawnSecondShip = false;
  70.                 }
  71.  
  72.                 // Sets current position
  73.                 this.pos.x = x;
  74.                 this.pos.y = y;
  75.  
  76.     }      
  77.  
  78.     });
  79. });
RAW Paste Data