src/enemy.js
/*
 * Base mixin for enemies.
 *
 * Spawn properties:
 * position: Enemy position
 */
Base mixin for enemies.
Spawn properties:
position: Enemy position
Base mixin for enemies . Spawn properties : position : Enemy position
function Enemy(game, args, type) {
	var position = args.position;
	var body = new p2.Body({
		position: args.position,
		angle: Math.PI * 0.5 + (args.angle || 0),
		mass: type.mass,
		gravityScale: 0,
	});
	var shape;
	if (type.isBox) {
		shape = new p2.Box({ width: 1, height: 1 });
	} else {
		shape = new p2.Circle({ radius: 1 });
	}
	shape.collisionGroup = physics.Mask.Enemy;
	shape.collisionMask = physics.Mask.World | physics.Mask.Player;
	body.addShape(shape);
	this.body = body;
	this.hurtTween = null;
	this.color = vec4.clone(type.color);
	this.type = type;
	this.health = type.health;
	this.lockCount = 0;
}
function Enemy ( game , args , type ) { var position = args . position ; var body = new p2 . Body ( { position : args . position , angle : Math . PI * 0.5 + ( args . angle || 0 ) , mass : type . mass , gravityScale : 0 , } ) ; var shape ; if ( type . isBox ) { shape = new p2 . Box ( { width : 1 , height : 1 } ) ; } else { shape = new p2 . Circle ( { radius : 1 } ) ; } shape . collisionGroup = physics . Mask . Enemy ; shape . collisionMask = physics . Mask . World | physics . Mask . Player ; body . addShape ( shape ) ; this . body = body ; this . hurtTween = null ; this . color = vec4 . clone ( type . color ) ; this . type = type ; this . health = type . health ; this . lockCount = 0 ; }
Base mixin for enemies.
Base mixin for enemies .