custom mode rework, might be done
This commit is contained in:
@@ -62,7 +62,6 @@ const powerUps = {
|
||||
effect() {
|
||||
//only get ammo for guns player has
|
||||
let target;
|
||||
// console.log(b.inventory.length)
|
||||
if (b.inventory.length > 0) {
|
||||
//add ammo to a gun in inventory
|
||||
target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]];
|
||||
@@ -302,36 +301,35 @@ const powerUps = {
|
||||
}
|
||||
},
|
||||
spawn(x, y, target, moving = true, mode = null) {
|
||||
if (!level.isBuildRun || target === "heal" || target === "ammo") {
|
||||
let index = powerUp.length;
|
||||
target = powerUps[target];
|
||||
size = target.size();
|
||||
powerUp[index] = Matter.Bodies.polygon(x, y, 0, size, {
|
||||
density: 0.001,
|
||||
frictionAir: 0.01,
|
||||
restitution: 0.8,
|
||||
inertia: Infinity, //prevents rotation
|
||||
collisionFilter: {
|
||||
group: 0,
|
||||
category: cat.powerUp,
|
||||
mask: cat.map | cat.powerUp
|
||||
},
|
||||
color: target.color,
|
||||
effect: target.effect,
|
||||
name: target.name,
|
||||
size: size
|
||||
});
|
||||
if (mode) {
|
||||
// console.log(mode)
|
||||
powerUp[index].mode = mode
|
||||
}
|
||||
if (moving) {
|
||||
Matter.Body.setVelocity(powerUp[index], {
|
||||
x: (Math.random() - 0.5) * 15,
|
||||
y: Math.random() * -9 - 3
|
||||
});
|
||||
}
|
||||
World.add(engine.world, powerUp[index]); //add to world
|
||||
// if (!level.isBuildRun || target === "heal" || target === "ammo") {
|
||||
let index = powerUp.length;
|
||||
target = powerUps[target];
|
||||
size = target.size();
|
||||
powerUp[index] = Matter.Bodies.polygon(x, y, 0, size, {
|
||||
density: 0.001,
|
||||
frictionAir: 0.01,
|
||||
restitution: 0.8,
|
||||
inertia: Infinity, //prevents rotation
|
||||
collisionFilter: {
|
||||
group: 0,
|
||||
category: cat.powerUp,
|
||||
mask: cat.map | cat.powerUp
|
||||
},
|
||||
color: target.color,
|
||||
effect: target.effect,
|
||||
name: target.name,
|
||||
size: size
|
||||
});
|
||||
if (mode) {
|
||||
powerUp[index].mode = mode
|
||||
}
|
||||
if (moving) {
|
||||
Matter.Body.setVelocity(powerUp[index], {
|
||||
x: (Math.random() - 0.5) * 15,
|
||||
y: Math.random() * -9 - 3
|
||||
});
|
||||
}
|
||||
World.add(engine.world, powerUp[index]); //add to world
|
||||
// }
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user