Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ig.module(
- 'game.entities.projectile'
- )
- .requires(
- 'impact.entity',
- 'plugins.entitytype'
- )
- .defines(function(){
- EntityProjectile = ig.Entity.extend({
- size: {x: 4, y: 4},
- offset: {x: 1, y: 1},
- gravityFactor: 0,
- collides: ig.Entity.COLLIDES.LITE,
- type: ig.Entity.TYPE.get("projectile"),
- animSheet: new ig.AnimationSheet( 'media/portalProjectileRed.png', 5, 5 ),
- speed: 350,
- init: function( x, y, settings ) {
- this.parent( x, y, settings );
- this.addAnim( 'idle', 0.1, [0,1] );
- this.maxVel.x = 500;
- this.maxVel.y = 500;
- //set click position in relation to player. player is always in the middle of the screen.
- var mx = settings.mouse.x - ig.system.width/2;
- var my = settings.mouse.y - ig.system.height/2;
- //calculate the length
- var vLength = Math.sqrt( Math.pow(mx ,2) + Math.pow(my ,2) );
- this.vel.x = (mx/vLength)*this.speed;
- this.vel.y = (my/vLength)*this.speed;
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement