Advertisement
Guest User

Untitled

a guest
Mar 10th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ig.module(
  2.     'game.entities.projectile'
  3. )
  4. .requires(
  5.     'impact.entity',
  6.     'plugins.entitytype'
  7. )
  8. .defines(function(){
  9.  
  10. EntityProjectile = ig.Entity.extend({
  11.     size: {x: 4, y: 4},
  12.     offset: {x: 1, y: 1},
  13.     gravityFactor: 0,
  14.    
  15.     collides: ig.Entity.COLLIDES.LITE,
  16.     type: ig.Entity.TYPE.get("projectile"),
  17.    
  18.     animSheet: new ig.AnimationSheet( 'media/portalProjectileRed.png', 5, 5 ),
  19.    
  20.     speed: 350,
  21.    
  22.     init: function( x, y, settings ) {
  23.        
  24.         this.parent( x, y, settings );
  25.        
  26.         this.addAnim( 'idle', 0.1, [0,1] );
  27.         this.maxVel.x = 500;
  28.         this.maxVel.y = 500;
  29.        
  30.         //set click position in relation to player. player is always in the middle of the screen.
  31.         var mx = settings.mouse.x - ig.system.width/2;
  32.         var my = settings.mouse.y - ig.system.height/2;
  33.        
  34.         //calculate the length
  35.         var vLength = Math.sqrt( Math.pow(mx ,2) + Math.pow(my ,2) );
  36.        
  37.         this.vel.x = (mx/vLength)*this.speed;
  38.         this.vel.y = (my/vLength)*this.speed;
  39.        
  40.     }
  41.    
  42. });
  43.  
  44.  
  45.  
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement