Add a boss to flail at you menacingly
This commit is contained in:
parent
f2c89402a3
commit
43b7ccfd0b
6 changed files with 176 additions and 0 deletions
BIN
assets/sprites/boss.png
Normal file
BIN
assets/sprites/boss.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
assets/sprites/tentacle.png
Normal file
BIN
assets/sprites/tentacle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 341 B |
|
@ -25,6 +25,11 @@ cavern_blank: {background: {image: "cavern", width: 3072}, tint: {rgb: 0xC030C0,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LevelDatabase["Boss Test"] = {music: "boss", background: {image: "cavern", width: 3072}, tint: {rgb: 0xB05000, a: 0.8, effect: "MULTIPLY"},
|
||||||
|
axes: [{x: 0, y: 0, radius: -512, angle: 0, length: 360, left: [0], right: [0]}],
|
||||||
|
boss: 1,
|
||||||
|
rocks: [], keys: [], doors: [], transitions: [], spawn: {axis: 0, position: 1, z: 0}};
|
||||||
|
|
||||||
LevelDatabase["Test Level"] = {
|
LevelDatabase["Test Level"] = {
|
||||||
|
|
||||||
//tint: {rgb: 0xB05000, a: 0.8, effect: "MULTIPLY"}, // Final boss tint?
|
//tint: {rgb: 0xB05000, a: 0.8, effect: "MULTIPLY"}, // Final boss tint?
|
||||||
|
|
135
level/Boss.js
Normal file
135
level/Boss.js
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
Boss = function(level, x, y, z, mode, dolphin) {
|
||||||
|
var boss = Entity(level, x, y, z);
|
||||||
|
|
||||||
|
var arms = [];
|
||||||
|
var armBbox = {
|
||||||
|
x: 12, y: 12, z: 12, tag: "tentacle"
|
||||||
|
};
|
||||||
|
for (var i = 0; i < 4; i++) {
|
||||||
|
var arm = [];
|
||||||
|
for (var j = 0; j < 10; j++) {
|
||||||
|
var tentacle = Entity(level, x, y, z);
|
||||||
|
|
||||||
|
tentacle.bbox = armBbox;
|
||||||
|
|
||||||
|
tentacle.momentum = {x: 0, y: 0, z: 0};
|
||||||
|
|
||||||
|
tentacle.addSprite("spr", Renderer.sprite("tentacle"));
|
||||||
|
tentacle.currentSprite("spr");
|
||||||
|
|
||||||
|
arm.push(tentacle);
|
||||||
|
}
|
||||||
|
arms.push(arm);
|
||||||
|
}
|
||||||
|
|
||||||
|
boss.arms = arms;
|
||||||
|
|
||||||
|
boss.addSprite("spr", Renderer.sprite("boss"));
|
||||||
|
boss.currentSprite("spr");
|
||||||
|
|
||||||
|
var targets = [
|
||||||
|
{x: x+150, y: y, z: z, stick: Math.floor(Math.random(80)+120)},
|
||||||
|
{x: x, y: y+150, z: z, stick: Math.floor(Math.random(80)+120)},
|
||||||
|
{x: x-150, y: y, z: z, stick: Math.floor(Math.random(80)+120)},
|
||||||
|
{x: x, y: y-150, z: z, stick: Math.floor(Math.random(80)+120)},
|
||||||
|
];
|
||||||
|
|
||||||
|
function positionArm(arm, target) {
|
||||||
|
// Figure out where the arm starts attached
|
||||||
|
var base = {
|
||||||
|
x: target.x - boss.position.x,
|
||||||
|
y: target.y - boss.position.y,
|
||||||
|
z: boss.position.z + 70
|
||||||
|
};
|
||||||
|
|
||||||
|
var dist = Math.sqrt(base.x * base.x + base.y * base.y)/70;
|
||||||
|
base.x /= dist;
|
||||||
|
base.y /= dist;
|
||||||
|
base.x += boss.position.x;
|
||||||
|
base.y += boss.position.y;
|
||||||
|
|
||||||
|
// Set first link to the base, and last link to the target.
|
||||||
|
var end = arm.length - 1;
|
||||||
|
arm[0].position.x = base.x;
|
||||||
|
arm[0].position.y = base.y;
|
||||||
|
arm[0].position.z = base.z;
|
||||||
|
arm[end].position.x = target.x;
|
||||||
|
arm[end].position.y = target.y;
|
||||||
|
arm[end].position.z = target.z;
|
||||||
|
|
||||||
|
// Do gravity, momentum, and pulling on each link between themselves.
|
||||||
|
while (end--) {
|
||||||
|
var one = arm[end];
|
||||||
|
var two = arm[end + 1];
|
||||||
|
|
||||||
|
var xdist = two.position.x - one.position.x;
|
||||||
|
var ydist = two.position.y - one.position.y;
|
||||||
|
var zdist = two.position.z - one.position.z;
|
||||||
|
|
||||||
|
dist = Math.sqrt(xdist * xdist + ydist * ydist + zdist * zdist);
|
||||||
|
|
||||||
|
if (dist > 34) {
|
||||||
|
one.momentum.x += xdist/16;
|
||||||
|
one.momentum.y += ydist/16;
|
||||||
|
one.momentum.z += zdist/16;
|
||||||
|
two.momentum.x -= xdist/16;
|
||||||
|
two.momentum.y -= ydist/16;
|
||||||
|
two.momentum.z -= zdist/16;
|
||||||
|
}
|
||||||
|
|
||||||
|
one.position.x += one.momentum.x;
|
||||||
|
one.position.y += one.momentum.y;
|
||||||
|
one.position.z += one.momentum.z;
|
||||||
|
|
||||||
|
one.momentum.x *= 0.9;
|
||||||
|
one.momentum.y *= 0.9;
|
||||||
|
one.momentum.z *= 0.9;
|
||||||
|
one.momentum.z += 0.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boss.think = function() {
|
||||||
|
var momx = dolphin.position.x + Math.cos(dolphin.angle) * 250 - boss.position.x;
|
||||||
|
var momy = dolphin.position.y + Math.sin(dolphin.angle) * 250 - boss.position.y;
|
||||||
|
var momz = dolphin.position.z - boss.position.z;
|
||||||
|
momx /= 16;
|
||||||
|
momy /= 16;
|
||||||
|
momz /= 16;
|
||||||
|
|
||||||
|
boss.position.x += momx;
|
||||||
|
boss.position.y += momy;
|
||||||
|
boss.position.z += momz;
|
||||||
|
|
||||||
|
var offset = level.ticCount;
|
||||||
|
|
||||||
|
targets.forEach(function(t) {
|
||||||
|
offset += 90;
|
||||||
|
t.stick--;
|
||||||
|
if (t.stick < -80) {
|
||||||
|
t.stick = Math.floor(Math.random() * 100 + 160);
|
||||||
|
} else if (t.stick == 0) {
|
||||||
|
var xoffs = -Math.sin(dolphin.angle) * Math.cos(dolphin.activeSprite.rotation) * 70;
|
||||||
|
var yoffs = Math.cos(dolphin.angle) * Math.cos(dolphin.activeSprite.rotation) * 70;
|
||||||
|
var zoffs = Math.sin(dolphin.activeSprite.rotation) * 70;
|
||||||
|
|
||||||
|
t.x = boss.position.x + (dolphin.position.x + xoffs - boss.position.x) * 2;
|
||||||
|
t.y = boss.position.y + (dolphin.position.y + yoffs - boss.position.y) * 2;
|
||||||
|
t.z = boss.position.z + (dolphin.position.z + zoffs - boss.position.z) * 2;
|
||||||
|
} else if (t.stick > 0) {
|
||||||
|
momx = boss.position.x + Math.cos(offset*Math.PI/180) * 150 - t.x;
|
||||||
|
momy = boss.position.y + Math.sin(offset*Math.PI/180) * 150 - t.y;
|
||||||
|
momz = boss.position.z - t.z;
|
||||||
|
|
||||||
|
t.x += momx/20;
|
||||||
|
t.y += momy/20;
|
||||||
|
t.z += momz/20;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var i = 0; i < 4; i++) {
|
||||||
|
positionArm(arms[i], targets[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boss;
|
||||||
|
};
|
|
@ -64,6 +64,21 @@ Dolphin = function(level, axis, position, z) {
|
||||||
collectible.think = collectible.attract;
|
collectible.think = collectible.attract;
|
||||||
collectible.attractTarget = dolphin;
|
collectible.attractTarget = dolphin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dolphin.colliding("tentacle")) {
|
||||||
|
dolphin.momentum.x *= -1.3;
|
||||||
|
dolphin.momentum.y *= -1.3;
|
||||||
|
|
||||||
|
while (dolphin.momentum.x * dolphin.momentum.x + dolphin.momentum.y * dolphin.momentum.y > 1000) {
|
||||||
|
dolphin.momentum.x *= 0.99;
|
||||||
|
dolphin.momentum.y *= 0.99;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (dolphin.colliding("tentacle")) {
|
||||||
|
axisMove();
|
||||||
|
vMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dolphin.fliptimer = 0;
|
dolphin.fliptimer = 0;
|
||||||
|
|
|
@ -39,6 +39,9 @@ Level = function(levelName) {
|
||||||
tint.scale.set(500/8, 280/8);
|
tint.scale.set(500/8, 280/8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boss
|
||||||
|
var boss;
|
||||||
|
|
||||||
// Wipe in/out graphic
|
// Wipe in/out graphic
|
||||||
var wipe = level.wipe = new PIXI.Graphics();
|
var wipe = level.wipe = new PIXI.Graphics();
|
||||||
wipe.beginFill(0x000000);
|
wipe.beginFill(0x000000);
|
||||||
|
@ -139,6 +142,24 @@ Level = function(levelName) {
|
||||||
crystal.save = true;
|
crystal.save = true;
|
||||||
placeEntityInGrid(crystal);
|
placeEntityInGrid(crystal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boss.
|
||||||
|
if (level.map.boss) {
|
||||||
|
boss = Boss(
|
||||||
|
level,
|
||||||
|
dolphin.position.x + Math.cos(dolphin.angle) * 250,
|
||||||
|
dolphin.position.y + Math.sin(dolphin.angle) * 250,
|
||||||
|
dolphin.position.z,
|
||||||
|
level.map.boss,
|
||||||
|
dolphin
|
||||||
|
);
|
||||||
|
placeEntityInGrid(boss);
|
||||||
|
boss.arms.forEach(function(arm) {
|
||||||
|
arm.forEach(function(piece) {
|
||||||
|
placeEntityInGrid(piece);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level.think = function() {
|
level.think = function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue