Advertisement
papyhardcore

Untitled

Feb 19th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ig.module(
  2.         'game.entities.Player'
  3.         )
  4.         .requires(
  5.                 'impact.entity',
  6.                 'game.entities.BulletPlayer'
  7.                 )
  8.         .defines(function() {
  9.  
  10.             EntityPlayer = ig.Entity.extend({
  11.                 size: {x: 25, y: 32},
  12.                 collides: ig.Entity.COLLIDES.PASSIVE,
  13.                 animSheet: new ig.AnimationSheet('media/player.png', 25, 32),
  14.                 init: function(x, y, settings) {
  15.                     this.parent(x, y, settings);
  16.                     this.addAnim('anim', 0.1, [2, 3]);
  17.                     this.addAnim('left', 0.1, [0, 1]);
  18.                     this.addAnim('right', 0.1, [4, 5]);
  19.                    
  20.                 },
  21.                 update: function() {
  22.  
  23.                     this.vel.x = 0;
  24.                     this.vel.y = 0;
  25.  
  26.                     if (ig.input.state('down')) {
  27.                         this.vel.y = 200;
  28.                         this.currentAnim = this.anims.anim;
  29.                     }
  30.                     if (ig.input.state('up')) {
  31.                         this.currentAnim = this.anims.anim;
  32.                         this.vel.y = -200;
  33.                     }
  34.                     if (ig.input.state('right')) {
  35.                         this.currentAnim = this.anims.right;
  36.                         this.vel.x = 200;
  37.                     }
  38.                     if (ig.input.state('left')) {
  39.                         this.currentAnim = this.anims.left;
  40.                         this.vel.x = -200;
  41.                     }
  42.                     if(ig.input.state('fire')){
  43.                         var bullet = new EntityBulletPlayer();
  44.                       ig.game.spawnEntity(EntityBullet,this.pos.x, this.pos.y);
  45.            
  46.                     }
  47.                     this.parent();
  48.  
  49.                 }
  50.  
  51.  
  52.  
  53.  
  54.             });
  55.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement