Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************************************8
- * StationaryShip.js
- * Small ship that helps the player and remains stationary
- * @copyright (c) 2013 Dave Voyles, under The MIT License (see LICENSE)
- *********************************************************************/
- ig.module(
- 'game.entities.StationaryShip'
- )
- .requires(
- 'game.entities.player'
- )
- .defines(function()
- {
- EntityStationaryShip = EntityPlayer.extend({
- name: 'StationaryShip',
- parental:null,
- type:ig.Entity.TYPE.NONE,
- checkAgainst: ig.Entity.TYPE.B, // Check Against B - our evil enemy group
- collides: ig.Entity.COLLIDES.PASSIVE,
- angle:0,
- bCanSpawnShip: true,
- bCanSpawnFirstShip: true,
- increase:0,
- totalWeapons: 4,
- activeWeapon: "EntityBullet",
- currentWeapLevel: 1,
- maxWeapLevels: 2,
- /******************************************8
- * Initialize
- ******************************************/
- init: function(x,y,settings){
- this.parent( x, y, settings );
- this.bCanSpawnShips = true;
- this.bCanSpawnFirstShip = true;
- // Used for constant fire
- this.lastShootTimer = new ig.Timer(0);
- },
- /******************************************8
- * Update
- ******************************************/
- update:function(x,y,settings){
- // Reference to player
- this.parental = ig.game.getEntitiesByType(EntityPlayer)[0];
- // Spawning offset location of ships vs. player
- var offsetX = 20;
- var offsetY = 40;
- // Spawn ships when "X" button is hit
- if (this.bCanSpawnFirstShip){
- // Spawns above the player
- x = this.parental.pos. x + offsetX;
- y = this.parental.pos.y + offsetY;
- this.bCanSpawnFirstShip = false;
- }
- // else (this.bCanSpawnSecondShip){
- else{
- // Spawns below player
- x = this.parental.pos.x + offsetX;
- y = this.parental.pos.y - offsetY;
- this.bCanSpawnSecondShip = false;
- }
- // Sets current position
- this.pos.x = x;
- this.pos.y = y;
- }
- });
- });
RAW Paste Data