papyhardcore

New Player.js file

Feb 10th, 2014
180
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. )
  7. .defines(function() {
  8.  
  9. EntityPlayer = ig.Entity.extend({
  10.                 size: {x: 150, y: 32},
  11.                 collides: ig.Entity.COLLIDES.FIXED,
  12.                 animSheet: ig.AnimationSheet('media/player.png', 150, 32),
  13.                
  14.                 init: function(x, y, settings) {
  15.                     this.parent(x, y, settings);
  16.                     this.addAnim('anim', 0.1, [0]);
  17.                 },
  18.                 update: function() {
  19.                    
  20.  
  21.                     if (ig.input.state('down')) {
  22.                         this.vel.y = 200;
  23.                         console.log("down");
  24.                     }
  25.                     if (ig.input.state('left')) {
  26.                         this.vel.x = -200;
  27.                         console.log("left");
  28.                     }
  29.                     if (ig.input.state('right')) {
  30.                         this.vel.x = 200;
  31.                         console.log("right");
  32.                     }
  33.                     if (ig.input.state('up')) {
  34.                         this.vel.y = -200;
  35.                         console.log("up");
  36.                     }
  37.                     if (ig.input.state('fire')) {
  38.                         console.log("fire");
  39.                     }
  40.                     if (ig.input.state('bomb')) {
  41.                         console.log("bomb");
  42.                     } else {
  43.                         console.log('none');
  44.                     }
  45.                     this.parent();
  46.  
  47.                 }
  48.  
  49.  
  50.  
  51.  
  52.             });
  53.         });
Advertisement
Add Comment
Please, Sign In to add comment