working on aeire level and suckerBoss
This commit is contained in:
28
js/mobs.js
28
js/mobs.js
@@ -554,7 +554,7 @@ const mobs = {
|
||||
// ctx.fillStyle = "rgba(0,0,0,0.1)";
|
||||
// ctx.fill();
|
||||
// },
|
||||
curl(range = 1000) {
|
||||
curl(range = 1000, mag = -10) {
|
||||
//cause all mobs, and bodies to rotate in a circle
|
||||
applyCurl = function (center, array) {
|
||||
for (let i = 0; i < array.length; ++i) {
|
||||
@@ -563,28 +563,26 @@ const mobs = {
|
||||
|
||||
//if too close, like center mob or shield, don't curl // if too far don't curl
|
||||
if (radius2 < range * range && radius2 > 10000) {
|
||||
const curlVector = Matter.Vector.perp(Matter.Vector.normalise(sub))
|
||||
|
||||
const curlVector = Matter.Vector.mult(Matter.Vector.perp(Matter.Vector.normalise(sub)), mag)
|
||||
//apply curl force
|
||||
const mag = Matter.Vector.mult(curlVector, 10)
|
||||
Matter.Body.setVelocity(array[i], {
|
||||
x: array[i].velocity.x * 0.94 + mag.x * 0.06,
|
||||
y: array[i].velocity.y * 0.94 + mag.y * 0.06
|
||||
x: array[i].velocity.x * 0.94 + curlVector.x * 0.06,
|
||||
y: array[i].velocity.y * 0.94 + curlVector.y * 0.06
|
||||
})
|
||||
|
||||
//draw curl
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(array[i].position.x, array[i].position.y);
|
||||
ctx.lineTo(array[i].position.x + curlVector.x * 100, array[i].position.y + curlVector.y * 100);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeStyle = "#000";
|
||||
ctx.stroke();
|
||||
// //draw curl
|
||||
// ctx.beginPath();
|
||||
// ctx.moveTo(array[i].position.x, array[i].position.y);
|
||||
// ctx.lineTo(array[i].position.x + curlVector.x * 10, array[i].position.y + curlVector.y * 10);
|
||||
// ctx.lineWidth = 2;
|
||||
// ctx.strokeStyle = "#000";
|
||||
// ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
applyCurl(this.position, mob);
|
||||
applyCurl(this.position, body);
|
||||
applyCurl(this.position, [player]);
|
||||
applyCurl(this.position, powerUp);
|
||||
// applyCurl(this.position, [player]);
|
||||
//draw limit
|
||||
// ctx.beginPath();
|
||||
// ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI);
|
||||
|
||||
Reference in New Issue
Block a user