papyhardcore

Player.js

Mar 2nd, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  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: 16, y: 16},
  11.                 collides: ig.Entity.COLLIDES.FIXED,
  12.                 animSheet: new ig.AnimationSheet('media/player.png',16, 16),
  13.                 init: function(x, y, settings) {
  14.                     this.parent(x, y, settings);
  15.                     this.addAnim('anim', 0.1, [0]);
  16.  
  17.                 },
  18.                 update: function() {
  19.  
  20.                     this.vel.x = 0;
  21.                     this.vel.y = 0;
  22.  
  23.                     if (ig.input.state('down')) {
  24.                         this.vel.y = 200;
  25.                         this.currentAnim = this.anims.anim;
  26.                     }
  27.                     if (ig.input.state('up')) {
  28.                         this.currentAnim = this.anims.anim;
  29.                         this.vel.y = -200;
  30.                     }
  31.                     if (ig.input.state('right')) {
  32.                         this.currentAnim = this.anims.anim;
  33.                         this.vel.x = 200;
  34.                     }
  35.                     if (ig.input.state('left')) {
  36.                         this.currentAnim = this.anims.anim;
  37.                         this.vel.x = -200;
  38.                     }
  39.                    
  40.                     this.parent();
  41.  
  42.                 }
  43.  
  44.  
  45.  
  46.  
  47.             });
  48.         });
Advertisement
Add Comment
Please, Sign In to add comment