lore conversations
to prevent misclicks when you grab two power ups in a row there is a 1/2 second delay before power up selections can register
I also added in a 0.25 fade in effect on the power up selection menu. Can you tell?
tech: pseudoscience - adds 0-4 JUNK to the potential tech pool (was 1-5 JUNK)
tech quenching - now increases max health and does harm for over healing from heal power ups
(was for heals at max health)
foam tech necrophoresis now makes less foam spawns if the total number of bullets is high
to help with lag when killing packs of mobs
preparation for more lore chapters
reworked the lore conversation code to make it easier to write
also lore conversations should now have better timing between the text and voice
lore conversations can now recover from some speech errors and try again with safer settings
this seems to allow speech on my firefox browser
added a console command to make it easier to quickly unlock testing mode
lore.unlockTesting()
pressing "b" in testing mode now gives you 10000 research and the damage from research tech
This commit is contained in:
@@ -392,10 +392,11 @@
|
|||||||
<!-- <text class="fade-in" fill='#aaa' stroke="none" x="30" y="45">Q</text>
|
<!-- <text class="fade-in" fill='#aaa' stroke="none" x="30" y="45">Q</text>
|
||||||
<text class="fade-in" fill='#aaa' stroke="none" x="170" y="45">E</text> -->
|
<text class="fade-in" fill='#aaa' stroke="none" x="170" y="45">E</text> -->
|
||||||
<text x="30" y="45" id="splash-previous-gun" stroke-width="2">Q</text>
|
<text x="30" y="45" id="splash-previous-gun" stroke-width="2">Q</text>
|
||||||
<text x="170" y="45" id="splash-next-gun" stroke-width="2">E</text>
|
|
||||||
<text x="100" y="45" id="splash-up">W</text>
|
<text x="100" y="45" id="splash-up">W</text>
|
||||||
<text x="100" y="113" id="splash-down">S</text>
|
<text x="170" y="45" id="splash-next-gun" stroke-width="2">E</text>
|
||||||
|
|
||||||
<text x="30" y="113" id="splash-left">A</text>
|
<text x="30" y="113" id="splash-left">A</text>
|
||||||
|
<text x="100" y="113" id="splash-down">S</text>
|
||||||
<text x="170" y="113" id="splash-right">D</text>
|
<text x="170" y="113" id="splash-right">D</text>
|
||||||
<!-- <text class="fade-in" fill='#999' x="100" y="45">W</text>
|
<!-- <text class="fade-in" fill='#999' x="100" y="45">W</text>
|
||||||
<text class="fade-in" fill='#999' x="100" y="113">S</text>
|
<text class="fade-in" fill='#999' x="100" y="113">S</text>
|
||||||
|
|||||||
@@ -2522,7 +2522,7 @@ const b = {
|
|||||||
this.target = null
|
this.target = null
|
||||||
this.collisionFilter.category = cat.bullet;
|
this.collisionFilter.category = cat.bullet;
|
||||||
this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
||||||
if (tech.isFoamGrowOnDeath && bullet.length < 250) {
|
if (tech.isFoamGrowOnDeath && bullet.length < 200) {
|
||||||
let targets = []
|
let targets = []
|
||||||
for (let i = 0, len = mob.length; i < len; i++) {
|
for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
|
const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
|
||||||
@@ -2531,7 +2531,8 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const radius = Math.min(this.radius * 0.5, 10)
|
const radius = Math.min(this.radius * 0.5, 10)
|
||||||
for (let i = 0; i < 2; i++) {
|
const len = bullet.length < 100 ? 2 : 1
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
if (targets.length - i > 0) {
|
if (targets.length - i > 0) {
|
||||||
const index = Math.floor(Math.random() * targets.length)
|
const index = Math.floor(Math.random() * targets.length)
|
||||||
const speed = 10 + 10 * Math.random()
|
const speed = 10 + 10 * Math.random()
|
||||||
|
|||||||
10
js/index.js
10
js/index.js
@@ -854,7 +854,11 @@ window.addEventListener("keydown", function(event) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='key-input-pause'>H</td>
|
<td class='key-input-pause'>H</td>
|
||||||
<td class='key-used'>brief harm immunity</td>
|
<td class='key-used'>harm immunity</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='key-input-pause'>B</td>
|
||||||
|
<td class='key-used'>damage, research</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='key-input-pause'>N</td>
|
<td class='key-input-pause'>N</td>
|
||||||
@@ -956,6 +960,10 @@ window.addEventListener("keydown", function(event) {
|
|||||||
case "y":
|
case "y":
|
||||||
tech.giveTech()
|
tech.giveTech()
|
||||||
break
|
break
|
||||||
|
case "b":
|
||||||
|
tech.isRerollDamage = true
|
||||||
|
powerUps.research.changeRerolls(100000)
|
||||||
|
break
|
||||||
case "r":
|
case "r":
|
||||||
m.resetHistory();
|
m.resetHistory();
|
||||||
Matter.Body.setPosition(player, simulation.mouseInGame);
|
Matter.Body.setPosition(player, simulation.mouseInGame);
|
||||||
|
|||||||
138
js/level.js
138
js/level.js
@@ -14,9 +14,9 @@ const level = {
|
|||||||
// simulation.enableConstructMode() //used to build maps in testing mode
|
// simulation.enableConstructMode() //used to build maps in testing mode
|
||||||
// level.difficultyIncrease(30)
|
// level.difficultyIncrease(30)
|
||||||
// simulation.isHorizontalFlipped = true
|
// simulation.isHorizontalFlipped = true
|
||||||
// m.setField("metamaterial cloaking")
|
// m.setField("wormhole")
|
||||||
// b.giveGuns("foam")
|
// b.giveGuns("foam")
|
||||||
// tech.giveTech("uncertainty principle")
|
// tech.giveTech("quenching")
|
||||||
// for (let i = 0; i < 9; i++) tech.giveTech("spherical harmonics")
|
// for (let i = 0; i < 9; i++) tech.giveTech("spherical harmonics")
|
||||||
// tech.giveTech("supertemporal")
|
// tech.giveTech("supertemporal")
|
||||||
// for (let i = 0; i < 3; i++) tech.giveTech("packet length")
|
// for (let i = 0; i < 3; i++) tech.giveTech("packet length")
|
||||||
@@ -47,12 +47,14 @@ const level = {
|
|||||||
// level.vats() //community level
|
// level.vats() //community level
|
||||||
// level["n-gon"]() //community level
|
// level["n-gon"]() //community level
|
||||||
// level.tunnel() //community level
|
// level.tunnel() //community level
|
||||||
// for (let i = 0; i < 39; i++) powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "tech", false);
|
// for (let i = 0; i < 3; i++) powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "tech", false);
|
||||||
// for (let i = 0; i < 7; i++) tech.giveTech("undefined")
|
// for (let i = 0; i < 7; i++) tech.giveTech("undefined")
|
||||||
// lore.techCount = 6
|
// lore.techCount = 6
|
||||||
// localSettings.loreCount = 1;
|
|
||||||
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
|
||||||
// simulation.isCheating = false //true;
|
// simulation.isCheating = false //true;
|
||||||
|
// localSettings.loreCount = 2; //this sets what conversation is heard
|
||||||
|
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
// level.onLevel = -1 //this sets level.levels[level.onLevel] = undefined which is required to run the conversation
|
||||||
// level.null()
|
// level.null()
|
||||||
} else {
|
} else {
|
||||||
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
|
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
|
||||||
@@ -87,7 +89,7 @@ const level = {
|
|||||||
powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "tech", false);
|
powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "tech", false);
|
||||||
}
|
}
|
||||||
if (tech.isHealLowHealth) {
|
if (tech.isHealLowHealth) {
|
||||||
const len = Math.ceil((m.maxHealth - m.health) / 0.25)
|
const len = Math.ceil((m.maxHealth - m.health) / 0.22)
|
||||||
for (let i = 0; i < len; i++) powerUps.spawn(player.position.x + 90 * (Math.random() - 0.5), player.position.y + 90 * (Math.random() - 0.5), "heal", false);
|
for (let i = 0; i < len; i++) powerUps.spawn(player.position.x + 90 * (Math.random() - 0.5), player.position.y + 90 * (Math.random() - 0.5), "heal", false);
|
||||||
}
|
}
|
||||||
if (tech.isMACHO) spawn.MACHO()
|
if (tech.isMACHO) spawn.MACHO()
|
||||||
@@ -1676,6 +1678,119 @@ const level = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
upDownOptions = [ //extra tall vertical section 3000x3000 //this is where the level boss is
|
upDownOptions = [ //extra tall vertical section 3000x3000 //this is where the level boss is
|
||||||
|
// (x = offset.x, y = offset.y) => {
|
||||||
|
// // spawn.mapVertex(x + 5, y + -1318, "0 0 0 -250 125 -250"); //left ledges
|
||||||
|
// // spawn.mapVertex(x + 1995, y + -1318, "0 0 0 -250 -125 -250"); // right ledges
|
||||||
|
|
||||||
|
// let r = 150
|
||||||
|
// const hexagon = `${r} 0 ${r*Math.cos(5.236)} ${r*Math.sin(5.236)} ${r*Math.cos(4.189)} ${r*Math.sin(4.189)} ${-r} 0 ${r*Math.cos(2.0944)} ${r*Math.sin(2.0944)} ${r*Math.cos(1.0472)} ${r*Math.sin(1.0472)} `
|
||||||
|
// //450 horizontal spread // -130-130-130 = 390 vertical
|
||||||
|
|
||||||
|
|
||||||
|
// let xOff = 100 + 225
|
||||||
|
// spawn.mapVertex(x + xOff + 0 * 450, y + -260 - 0 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -260 - 0 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -260 - 0 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -260 - 0 * 390, hexagon);
|
||||||
|
|
||||||
|
// xOff = 100
|
||||||
|
// // spawn.mapVertex(x + xOff + 0 * 450, y + 1 * -260 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -260 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -260 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -260 - 1 * 390, hexagon);
|
||||||
|
// // spawn.mapVertex(x + xOff + 4 * 450, y + 1 * -260 - 1 * 390, hexagon);
|
||||||
|
|
||||||
|
// xOff = 100 + 225
|
||||||
|
// spawn.mapVertex(x + xOff + 0 * 450, y + -260 - 2 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -260 - 2 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -260 - 2 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -260 - 2 * 390, hexagon);
|
||||||
|
|
||||||
|
// xOff = 100
|
||||||
|
// // spawn.mapVertex(x + xOff + 0 * 450, y + 1 * -260 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -260 - 3 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -260 - 3 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -260 - 3 * 390, hexagon);
|
||||||
|
// // spawn.mapVertex(x + xOff + 4 * 450, y + 1 * -260 - 1 * 390, hexagon);
|
||||||
|
|
||||||
|
// xOff = 100 + 225
|
||||||
|
// spawn.mapVertex(x + xOff + 0 * 450, y + -260 - 4 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -260 - 4 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -260 - 4 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -260 - 4 * 390, hexagon);
|
||||||
|
|
||||||
|
|
||||||
|
// //phase 2
|
||||||
|
// xOff = 100
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -130 - 0 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -130 - 0 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -130 - 0 * 390, hexagon);
|
||||||
|
|
||||||
|
// xOff = 100 + 225
|
||||||
|
// spawn.mapVertex(x + xOff + 0 * 450, y + -130 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -130 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -130 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -130 - 1 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 4 * 450, y + -130 - 1 * 390, hexagon);
|
||||||
|
// xOff = 100
|
||||||
|
// spawn.mapVertex(x + xOff + 1 * 450, y + -130 - 2 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 2 * 450, y + -130 - 2 * 390, hexagon);
|
||||||
|
// spawn.mapVertex(x + xOff + 3 * 450, y + -130 - 2 * 390, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 550, y + 1 * -260, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 550, y + 2 * -260, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 550, y + 3 * -260, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 550, y + 5 * -260, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 550, y + 4 * -260, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 775, y + -260, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1225, y + -260, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 550, y + -650, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1000, y + -650, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1450, y + -650, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 775, y + -1040, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1225, y + -1040, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 550, y + -1430, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1000, y + -1430, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1450, y + -1430, hexagon);
|
||||||
|
|
||||||
|
// // spawn.mapVertex(x + 775, y + -1820, hexagon);
|
||||||
|
// // spawn.mapVertex(x + 1225, y + -1820, hexagon);
|
||||||
|
|
||||||
|
// let count = 0
|
||||||
|
// doCustomTopLayer.push(
|
||||||
|
// () => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if (!(count % 60)) {
|
||||||
|
// addMapToLevelInProgress = (who) => { //adds new map elements to the level while the level is already running //don't forget to run simulation.draw.setPaths() after you all the the elements so they show up visually
|
||||||
|
// who.collisionFilter.category = cat.map;
|
||||||
|
// who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
|
||||||
|
// Matter.Body.setStatic(who, true); //make static
|
||||||
|
// World.add(engine.world, who); //add to world
|
||||||
|
// }
|
||||||
|
// const numberOfMapElementsAdded = 0
|
||||||
|
// for (let i = 0; i < numberOfMapElementsAdded; i++) addMapToLevelInProgress(map[map.length - 1 - i])
|
||||||
|
|
||||||
|
// simulation.draw.setPaths() //update map graphics
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// spawn.randomMob(x + 225, y + -1025, Infinity);
|
||||||
|
// spawn.randomMob(x + 200, y + -675, Infinity);
|
||||||
|
// spawn.randomMob(x + 225, y + -200, Infinity);
|
||||||
|
// spawn.randomMob(x + 1750, y + -1075, Infinity);
|
||||||
|
// spawn.randomMob(x + 1700, y + -650, Infinity);
|
||||||
|
// spawn.randomMob(x + 1675, y + -175, Infinity);
|
||||||
|
|
||||||
|
// spawn.randomGroup(x + 300, y + -2200);
|
||||||
|
// spawn.randomGroup(x + 1625, y + -2200);
|
||||||
|
// spawn.randomLevelBoss(x + 950, y + -2200);
|
||||||
|
|
||||||
|
// },
|
||||||
(x = offset.x, y = offset.y) => {
|
(x = offset.x, y = offset.y) => {
|
||||||
const toggle = level.toggle(x + 950, y + 0, false, true) // toggle(x, y, isOn = false, isLockOn = false) {
|
const toggle = level.toggle(x + 950, y + 0, false, true) // toggle(x, y, isOn = false, isLockOn = false) {
|
||||||
toggle.isAddedElements = false
|
toggle.isAddedElements = false
|
||||||
@@ -1856,7 +1971,7 @@ const level = {
|
|||||||
empty = emptyOptions[Math.floor(Math.random() * emptyOptions.length)];
|
empty = emptyOptions[Math.floor(Math.random() * emptyOptions.length)];
|
||||||
loot = lootOptions[Math.floor(Math.random() * lootOptions.length)];
|
loot = lootOptions[Math.floor(Math.random() * lootOptions.length)];
|
||||||
upDown = upDownOptions[Math.floor(Math.random() * upDownOptions.length)];
|
upDown = upDownOptions[Math.floor(Math.random() * upDownOptions.length)];
|
||||||
// empty = emptyOptions[2] //controls what level spawns for map designing building //********************************* DO !NOT! RUN THIS LINE IN THE FINAL VERSION ***************************************
|
// upDown = upDownOptions[0] //controls what level spawns for map designing building //********************************* DO !NOT! RUN THIS LINE IN THE FINAL VERSION ***************************************
|
||||||
//3x2: 4 short rooms (3000x1500), 1 double tall room (3000x3000)
|
//3x2: 4 short rooms (3000x1500), 1 double tall room (3000x3000)
|
||||||
//rooms
|
//rooms
|
||||||
let rooms = ["loot", "enter", "empty", "exit"]
|
let rooms = ["loot", "enter", "empty", "exit"]
|
||||||
@@ -1965,7 +2080,14 @@ const level = {
|
|||||||
null() {
|
null() {
|
||||||
level.levels.pop(); //remove lore level from rotation
|
level.levels.pop(); //remove lore level from rotation
|
||||||
//start a conversation based on the number of conversations seen
|
//start a conversation based on the number of conversations seen
|
||||||
if (!simulation.isCheating && localSettings.loreCount < lore.conversation.length) lore.conversation[localSettings.loreCount]()
|
if (localSettings.loreCount < lore.conversation.length && !simulation.isCheating) {
|
||||||
|
lore.chapter = localSettings.loreCount //set the chapter to listen to to be the lore level (you can't use the lore level because it changes during conversations)
|
||||||
|
lore.sentence = 0 //what part of the conversation to start on
|
||||||
|
lore.conversation[lore.chapter][lore.sentence]()
|
||||||
|
|
||||||
|
localSettings.loreCount++ //hear the next conversation next time you win
|
||||||
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
}
|
||||||
|
|
||||||
const hazardSlime = level.hazard(-1800, 150, 3600, 650, 0.004, "hsla(160, 100%, 35%,0.75)")
|
const hazardSlime = level.hazard(-1800, 150, 3600, 650, 0.004, "hsla(160, 100%, 35%,0.75)")
|
||||||
const circle = {
|
const circle = {
|
||||||
|
|||||||
622
js/lore.js
622
js/lore.js
@@ -2,153 +2,527 @@ const lore = {
|
|||||||
techCount: 0,
|
techCount: 0,
|
||||||
techGoal: 7,
|
techGoal: 7,
|
||||||
talkingColor: "#dff", //set color of graphic on level.null
|
talkingColor: "#dff", //set color of graphic on level.null
|
||||||
|
// anand: {
|
||||||
|
// color: "#e0c",
|
||||||
|
// text: function(say, isSpeech = false) {
|
||||||
|
// if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
||||||
|
// simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
||||||
|
// lore.talkingColor = this.color
|
||||||
|
// if (isSpeech) this.speech(say)
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// speech: function(say) {
|
||||||
|
// var utterance = new SpeechSynthesisUtterance(say);
|
||||||
|
// utterance.lang = "en-IN";
|
||||||
|
// utterance.volume = 0.2; // 0 to 1
|
||||||
|
// speechSynthesis.speak(utterance);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// miriamOld: {
|
||||||
|
// color: "#f20",
|
||||||
|
// text: function(say, isSpeech = false) {
|
||||||
|
// if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
||||||
|
// simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
||||||
|
// lore.talkingColor = this.color
|
||||||
|
// if (isSpeech) this.speech(say)
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// speech: function(say) {
|
||||||
|
// var utterance = new SpeechSynthesisUtterance(say);
|
||||||
|
// utterance.lang = "en-AU";
|
||||||
|
// utterance.volume = 0.2; // 0 to 1
|
||||||
|
// speechSynthesis.speak(utterance);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
|
// voices = synth.getVoices();
|
||||||
|
|
||||||
|
// for(i = 0; i < voices.length ; i++) {
|
||||||
|
// var option = document.createElement('option');
|
||||||
|
// option.textContent = voices[i].name + ' (' + voices[i].lang + ')';
|
||||||
|
|
||||||
|
// if(voices[i].default) {
|
||||||
|
// option.textContent += ' -- DEFAULT';
|
||||||
|
// }
|
||||||
|
|
||||||
|
// option.setAttribute('data-lang', voices[i].lang);
|
||||||
|
// option.setAttribute('data-name', voices[i].name);
|
||||||
|
// voiceSelect.appendChild(option);
|
||||||
|
// }
|
||||||
|
setVoices() {
|
||||||
|
window.speechSynthesis.onvoiceschanged = () => {
|
||||||
|
const synth = window.speechSynthesis
|
||||||
|
console.log(synth.getVoices())
|
||||||
|
const voiceArray = synth.getVoices()
|
||||||
|
lore.anand.voice = voiceArray[0]
|
||||||
|
lore.miriam.voice = voiceArray[1]
|
||||||
|
console.log(voiceArray[0], voiceArray[1])
|
||||||
|
};
|
||||||
|
// console.log('before')
|
||||||
|
// if ('speechSynthesis' in window) {
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// console.log('Text-to-speech not supported.');
|
||||||
|
// }
|
||||||
|
},
|
||||||
anand: {
|
anand: {
|
||||||
color: "#e0c",
|
color: "#e0c",
|
||||||
text: function(say, isSpeech = false) {
|
voice: undefined,
|
||||||
|
text: function(say) {
|
||||||
if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
||||||
simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
||||||
lore.talkingColor = this.color
|
lore.talkingColor = this.color
|
||||||
if (isSpeech) this.speech(say)
|
const utterance = new SpeechSynthesisUtterance(say);
|
||||||
|
// utterance.voice = lore.anand.voice
|
||||||
|
utterance.lang = "en-GB" //"en-IN"; //de-DE en-GB fr-FR en-US en-AU
|
||||||
|
utterance.volume = 0.2; // 0 to 1
|
||||||
|
// utterance.rate = 1.5
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
utterance.onerror = (event) => { //if speech doesn't work try again without the lang set
|
||||||
|
console.log("speech error", event.error)
|
||||||
|
const utterance = new SpeechSynthesisUtterance(say);
|
||||||
|
utterance.volume = 0.2; // 0 to 1
|
||||||
|
speechSynthesis.speak(utterance);
|
||||||
|
utterance.onend = () => {
|
||||||
|
lore.sentence++
|
||||||
|
if (m.alive) lore.conversation[lore.chapter][lore.sentence]() //go to next sentence in the chapter and play it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utterance.onend = () => {
|
||||||
|
lore.sentence++
|
||||||
|
if (m.alive) lore.conversation[lore.chapter][lore.sentence]() //go to next sentence in the chapter and play it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
speech: function(say) {
|
|
||||||
var utterance = new SpeechSynthesisUtterance(say);
|
|
||||||
utterance.lang = "en-IN";
|
|
||||||
utterance.volume = 0.2; // 0 to 1
|
|
||||||
speechSynthesis.speak(utterance);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
miriam: {
|
miriam: {
|
||||||
color: "#f20",
|
color: "#f20",
|
||||||
text: function(say, isSpeech = false) {
|
text: function(say) {
|
||||||
if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
if (level.levels[level.onLevel] === undefined) { //only talk if on the lore level (which is undefined because it is popped out of the level.levels array)
|
||||||
simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
simulation.makeTextLog(`input.audio(<span style="color:#888; font-size: 70%;">${Date.now()} ms</span>)<span class='color-symbol'>:</span> "<span style="color:${this.color};">${say}</span>"`, Infinity);
|
||||||
lore.talkingColor = this.color
|
lore.talkingColor = this.color
|
||||||
if (isSpeech) this.speech(say)
|
utterance = new SpeechSynthesisUtterance(say);
|
||||||
}
|
// utterance.voice = lore.anand.voice
|
||||||
},
|
utterance.lang = "en-AU";
|
||||||
speech: function(say) {
|
utterance.volume = 0.2; // 0 to 1
|
||||||
var utterance = new SpeechSynthesisUtterance(say);
|
// utterance.rate = 1.5
|
||||||
utterance.lang = "en-AU";
|
speechSynthesis.speak(utterance);
|
||||||
utterance.volume = 0.2; // 0 to 1
|
utterance.onerror = (event) => { //if speech doesn't work try again without the lang set
|
||||||
speechSynthesis.speak(utterance);
|
console.log("speech error", event.error)
|
||||||
}
|
const utterance = new SpeechSynthesisUtterance(say);
|
||||||
},
|
utterance.volume = 0.2; // 0 to 1
|
||||||
conversation: [
|
speechSynthesis.speak(utterance);
|
||||||
() => {
|
utterance.onend = () => {
|
||||||
if (localSettings.loreCount < 1) {
|
lore.sentence++
|
||||||
localSettings.loreCount = 1
|
if (m.alive) lore.conversation[lore.chapter][lore.sentence]() //go to next sentence in the chapter and play it
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
}
|
||||||
document.getElementById("control-testing").style.visibility = (localSettings.loreCount === 0) ? "hidden" : "visible"
|
}
|
||||||
document.getElementById("experiment-button").style.visibility = (localSettings.loreCount === 0) ? "hidden" : "visible"
|
utterance.onend = () => {
|
||||||
}
|
lore.sentence++
|
||||||
let delay = 6000
|
if (m.alive) lore.conversation[lore.chapter][lore.sentence]() //go to next sentence in the chapter and play it
|
||||||
setTimeout(() => { lore.miriam.text("I've never seen it generate this level before.", true) }, delay);
|
|
||||||
delay += 2700
|
|
||||||
setTimeout(() => { lore.anand.text("Wow. Just a platform.", true) }, delay);
|
|
||||||
delay += 2200
|
|
||||||
setTimeout(() => { lore.miriam.text("And that thing...", true) }, delay);
|
|
||||||
delay += 1500
|
|
||||||
setTimeout(() => { lore.anand.text("Weird", true) }, delay);
|
|
||||||
delay += 1500
|
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
|
||||||
delay += 1000
|
|
||||||
setTimeout(() => { lore.anand.text("Maybe it's trapped.", true) }, delay);
|
|
||||||
delay += 2300
|
|
||||||
setTimeout(() => { lore.miriam.text('Hey little bot! Just press "T" to enter testing mode and "U" to go to the next level.', true) }, delay);
|
|
||||||
delay += 5400
|
|
||||||
setTimeout(() => { lore.anand.text("I don't think it's connected to the audio input, and I'm sure it can't understand what you're saying.", true) }, delay);
|
|
||||||
delay += 5300
|
|
||||||
setTimeout(() => { lore.miriam.text("ha hahahaha. I know, but it does seem to be getting smarter.", true) }, delay);
|
|
||||||
delay += 3700
|
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
|
||||||
delay += 25000
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!simulation.isCheating) {
|
|
||||||
lore.miriam.text("Poor thing... I hope it figures out how to escape.", true)
|
|
||||||
delay += 3500
|
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
|
||||||
}
|
}
|
||||||
}, delay);
|
|
||||||
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
if (localSettings.loreCount < 2) {
|
|
||||||
localSettings.loreCount = 2
|
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
|
||||||
}
|
}
|
||||||
let delay = 6000
|
},
|
||||||
setTimeout(() => { lore.miriam.text("Hey look! It's back at the weird level again!", true) }, delay);
|
},
|
||||||
delay += 2500
|
// setTimeout(() => {}, 2000);
|
||||||
setTimeout(() => { lore.anand.text("oh Wow! Why does it keep making this level?", true) }, delay);
|
// lore.miriam.text("")
|
||||||
delay += 2900
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
setTimeout(() => { lore.miriam.text("I don't know, but last time it was in this room I think it understood us.", true) }, delay);
|
// })
|
||||||
delay += 4000
|
chapter: 0, //what part of the conversation is playing
|
||||||
setTimeout(() => { lore.miriam.text("Let's try talking to it again.", true) }, delay);
|
sentence: 0, //what part of the conversation is playing
|
||||||
delay += 2500
|
conversation: [
|
||||||
setTimeout(() => { lore.miriam.text("hmmm, what should we say?", true) }, delay);
|
[ //first time they meet, and testing gets unlocked
|
||||||
delay += 2500
|
() => {
|
||||||
setTimeout(() => { lore.anand.text("I'm still not convinced it understands. We need a test.", true) }, delay);
|
// lore.setVoices();
|
||||||
delay += 4000
|
setTimeout(() => {
|
||||||
setTimeout(() => { lore.miriam.text("Hey bot!!!", true) }, delay);
|
lore.miriam.text("I've never seen it generate this level before.")
|
||||||
delay += 1300
|
}, 5000);
|
||||||
setTimeout(() => { lore.miriam.text("If you can understand me crouch", true) }, delay);
|
},
|
||||||
delay += 1500
|
() => { lore.anand.text("Wow. Just a platform.") },
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
() => { lore.miriam.text("And that thing...") },
|
||||||
setTimeout(() => {
|
() => { lore.anand.text("Weird") },
|
||||||
|
() => { lore.anand.text("Maybe it's trapped.") },
|
||||||
|
() => {
|
||||||
|
lore.miriam.text("Hey little bot! Just press 'T' to enter testing mode and 'U' to go to the next level.")
|
||||||
|
lore.unlockTesting();
|
||||||
|
},
|
||||||
|
() => { lore.anand.text("I don't think it's connected to the audio input, and I'm sure it can't understand what you're saying.") },
|
||||||
|
() => { lore.miriam.text("ha hahahaha. I know, but it does seem to be getting smarter.") },
|
||||||
|
() => {
|
||||||
|
lore.talkingColor = "#dff"
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.miriam.text("Poor thing... I hope it figures out how to escape.")
|
||||||
|
}, 25000);
|
||||||
|
},
|
||||||
|
() => { lore.talkingColor = "#dff" },
|
||||||
|
],
|
||||||
|
[ //they learn the bot can understand what they say
|
||||||
|
() => { setTimeout(() => { lore.miriam.text("Hey look! It's back at the weird level again!") }, 5000); },
|
||||||
|
() => { lore.anand.text("oh Wow! Why does it keep making this level?") },
|
||||||
|
() => { lore.miriam.text("I don't know, but last time it was in this room I think it understood us.") },
|
||||||
|
() => { lore.miriam.text("Let's try talking to it again.") },
|
||||||
|
() => { lore.miriam.text("hmmm, what should we say?") },
|
||||||
|
() => { lore.anand.text("I'm still not convinced it understands. We need a test.") },
|
||||||
|
() => { setTimeout(() => { lore.miriam.text("Hey bot!!!") }, 1000); },
|
||||||
|
() => { lore.miriam.text("If you can understand me crouch") },
|
||||||
|
() => {
|
||||||
|
lore.talkingColor = "#dff"
|
||||||
|
|
||||||
function cycle() {
|
function cycle() {
|
||||||
if (input.down) {
|
if (input.down) {
|
||||||
let delay = 500 //reset delay time
|
lore.miriam.text("Look, It did it! It crouched.")
|
||||||
setTimeout(() => { lore.miriam.text("Look, It did it! It crouched.", true) }, delay);
|
|
||||||
delay += 2000
|
|
||||||
setTimeout(() => { lore.anand.text("Amazing! It can understand us...", true) }, delay);
|
|
||||||
delay += 2700
|
|
||||||
setTimeout(() => { lore.miriam.text("It's Alive... Or it just crouched randomly.", true) }, delay);
|
|
||||||
delay += 2800
|
|
||||||
setTimeout(() => { lore.miriam.text("Hey bot! Can you crouch again?", true) }, delay);
|
|
||||||
delay += 2000
|
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
|
||||||
setTimeout(() => {
|
|
||||||
function cycle() {
|
|
||||||
if (input.down) {
|
|
||||||
let delay = 500 //reset delay time
|
|
||||||
setTimeout(() => { lore.miriam.text("It is Alive!!! ... hehehehehe ahahahahahah ehehehehe ahahahah", true) }, delay);
|
|
||||||
delay += 3500
|
|
||||||
setTimeout(() => { lore.anand.text("OK...", true) }, delay);
|
|
||||||
delay += 2700
|
|
||||||
setTimeout(() => { lore.anand.text("but seriously, this means that in this room it can monitor our audio, and it can understand us.", true) }, delay);
|
|
||||||
delay += 6400
|
|
||||||
setTimeout(() => { lore.anand.text("Anything we say could destabilize the project.", true) }, delay);
|
|
||||||
delay += 4200
|
|
||||||
setTimeout(() => { lore.miriam.text("Fine, Let's talk down stairs.", true) }, delay);
|
|
||||||
delay += 3000
|
|
||||||
setTimeout(() => { lore.miriam.text("Bye bye little bot.", true) }, delay);
|
|
||||||
delay += 2000
|
|
||||||
setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
|
||||||
} else {
|
|
||||||
requestAnimationFrame(cycle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requestAnimationFrame(cycle);
|
|
||||||
}, delay);
|
|
||||||
} else {
|
} else {
|
||||||
requestAnimationFrame(cycle);
|
if (m.alive) requestAnimationFrame(cycle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requestAnimationFrame(cycle);
|
requestAnimationFrame(cycle);
|
||||||
}, delay);
|
},
|
||||||
},
|
() => { lore.anand.text("Amazing! It can understand us...") },
|
||||||
() => {
|
() => { lore.miriam.text("It's Alive... Or it just crouched randomly.") },
|
||||||
// let delay = 6000
|
() => { lore.miriam.text("Hey bot! Can you crouch again?") },
|
||||||
// setTimeout(() => { lore.miriam.text("I've never seen it generate this level before.", true) }, delay);
|
() => {
|
||||||
// delay += 2700
|
lore.talkingColor = "#dff"
|
||||||
|
|
||||||
},
|
function cycle() {
|
||||||
],
|
if (input.down) {
|
||||||
dialogue: [
|
lore.miriam.text("It is Alive!!! ... hehehehehe! ahahahahahah ehehehehe, ahahahah ...")
|
||||||
``,
|
} else {
|
||||||
``,
|
if (m.alive) requestAnimationFrame(cycle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requestAnimationFrame(cycle);
|
||||||
|
},
|
||||||
|
() => { setTimeout(() => { lore.anand.text("OK ...") }, 1000); },
|
||||||
|
() => { lore.anand.text("but seriously, this means that in this room it can monitor our audio, and it can understand us.") },
|
||||||
|
() => { lore.anand.text("Anything we say could destabilize the project.") },
|
||||||
|
() => { lore.miriam.text("Fine, Let's talk down stairs.") },
|
||||||
|
() => { lore.miriam.text("Bye bye little bot.") },
|
||||||
|
() => { lore.talkingColor = "#dff" },
|
||||||
|
],
|
||||||
|
[ //they ask the bot questions, but waves of mobs come and attack
|
||||||
|
() => { lore.anand.text("Quick, get ready. It's back!") },
|
||||||
|
() => { lore.miriam.text("What's back?") },
|
||||||
|
() => { lore.anand.text("The bot is back on the communication level!") },
|
||||||
|
() => { lore.miriam.text("Oh good, I've got so many questions.") },
|
||||||
|
() => { lore.miriam.text("Is it self aware?") },
|
||||||
|
() => { lore.miriam.text("How did it learn to understand words?") },
|
||||||
|
() => { lore.miriam.text("Why can it only hear what we are saying on this level?") },
|
||||||
|
() => { lore.miriam.text("I wish we could just ask it questions directly, instead of yes or no.") },
|
||||||
|
() => { lore.anand.text("We could ask it to spell words by saying letters and having it crouching on the correct letter.") },
|
||||||
|
() => { lore.miriam.text("Well, that would take forever.") },
|
||||||
|
() => { lore.miriam.text("I really want to know: Why is it generating the mobs? and why does it keep fighting them?") },
|
||||||
|
() => {
|
||||||
|
lore.anand.text("Maybe that is just part of it's expectation–maximization algorithm")
|
||||||
|
|
||||||
|
//endlessly spawning mobs until the player dies
|
||||||
|
function cycle() {
|
||||||
|
if (!(simulation.cycle % 360)) {
|
||||||
|
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
|
||||||
|
spawn[pick](1000 * (Math.random() - 0.5), -500 + 200 * (Math.random() - 0.5));
|
||||||
|
level.difficultyIncrease(simulation.difficultyMode)
|
||||||
|
}
|
||||||
|
if (!(simulation.cycle % 900)) spawn.randomLevelBoss(500 * (Math.random() - 0.5), -500 + 200 * (Math.random() - 0.5))
|
||||||
|
if (m.alive) requestAnimationFrame(cycle);
|
||||||
|
}
|
||||||
|
requestAnimationFrame(cycle);
|
||||||
|
},
|
||||||
|
() => { lore.miriam.text("Well sure, but what does that even mean?") },
|
||||||
|
() => { lore.miriam.text("Do we all just do things because we are-") },
|
||||||
|
() => { lore.miriam.text("... what is going on?") },
|
||||||
|
() => { setTimeout(() => { lore.anand.text("it's spawning mobs and fighting them") }, 1000); },
|
||||||
|
() => { lore.miriam.text("oh no.") },
|
||||||
|
() => { lore.anand.text("We can't really communicate with it while it's fighting") },
|
||||||
|
() => { lore.miriam.text("You can do it little bot!") },
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.anand.text("But, why is it spawning these bots?")
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.anand.text("This is so strange.")
|
||||||
|
}, 3000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.miriam.text("This is chaos!")
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.anand.text("I don't understand this project.")
|
||||||
|
}, 3000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.miriam.text("It's fascinating though.")
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.miriam.text("I think this isn't going to end well.")
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.anand.text("Let's just be more prepared next time it enters this room.")
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
lore.talkingColor = "#dff";
|
||||||
|
lore.anand.text("I had to go to the bathroom. What happened while I was gone?")
|
||||||
|
}, 20000);
|
||||||
|
},
|
||||||
|
() => { lore.miriam.text("More fighting...") },
|
||||||
|
() => { lore.anand.text("great...") },
|
||||||
|
|
||||||
|
() => { lore.talkingColor = "#dff" },
|
||||||
|
],
|
||||||
|
// scientist try to think of a way to communicate since the bot can't talk
|
||||||
|
// they give up on getting the bot to respond, and just start ask questions and thinking of explanations with each other
|
||||||
|
// when and how did it become self-aware
|
||||||
|
// why is the bot fighting things in these simulated locations?
|
||||||
|
// it wasn't designed to be violent
|
||||||
|
// the bot was just designed to automate research and testing of new technology
|
||||||
|
// 3D architecture superconducting quantum computer
|
||||||
|
// running machine learning algorithms
|
||||||
|
// as the scientist start to get agitated bots arrive and player dies
|
||||||
|
// bots come in Infinite waves that increase game difficulty each wave
|
||||||
|
// only ending is testing mode + next level or player death
|
||||||
|
// scientist have some lines in between each wave of mobs
|
||||||
|
|
||||||
|
|
||||||
|
// () => {
|
||||||
|
// if (localSettings.loreCount < 2) {
|
||||||
|
// localSettings.loreCount = 2
|
||||||
|
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
// }
|
||||||
|
// setTimeout(() => {
|
||||||
|
// lore.miriam.text("Hey look! It's back at the weird level again!")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("oh Wow! Why does it keep making this level?")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("I don't know, but last time it was in this room I think it understood us.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Let's try talking to it again.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("hmmm, what should we say?")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("I'm still not convinced it understands. We need a test.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Hey bot!!!")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("If you can understand me crouch")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.talkingColor = "#dff"
|
||||||
|
|
||||||
|
// function cycle() {
|
||||||
|
// if (input.down) {
|
||||||
|
// lore.miriam.text("Look, It did it! It crouched.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("Amazing! It can understand us...")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("It's Alive... Or it just crouched randomly.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Hey bot! Can you crouch again?")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.talkingColor = "#dff"
|
||||||
|
|
||||||
|
// function cycle() {
|
||||||
|
// if (input.down) {
|
||||||
|
// lore.miriam.text("It is Alive!!! ... hehehehehe! ahahahahahah ehehehehe, ahahahah ...")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// lore.anand.text("OK ...")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("but seriously, this means that in this room it can monitor our audio, and it can understand us.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("Anything we say could destabilize the project.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Fine, Let's talk down stairs.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Bye bye little bot.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.talkingColor = "#dff"
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// }, 1500);
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// if (m.alive) requestAnimationFrame(cycle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// if (m.alive) requestAnimationFrame(cycle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }, 6000);
|
||||||
|
// },
|
||||||
|
// () => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// lore.miriam.text("I've never seen it generate this level before.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("Wow. Just a platform.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("And that thing...")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("Weird")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("Maybe it's trapped.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("Hey little bot! Just press 'T' to enter testing mode and 'U' to go to the next level.")
|
||||||
|
// lore.unlockTesting();
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.anand.text("I don't think it's connected to the audio input, and I'm sure it can't understand what you're saying.")
|
||||||
|
// lore.anand.utterance.addEventListener('end', () => {
|
||||||
|
// lore.miriam.text("ha hahahaha. I know, but it does seem to be getting smarter.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => {
|
||||||
|
// lore.talkingColor = "#dff" // when no one is talking
|
||||||
|
// setTimeout(() => {
|
||||||
|
// lore.miriam.text("Poor thing... I hope it figures out how to escape.")
|
||||||
|
// lore.miriam.utterance.addEventListener('end', () => { lore.talkingColor = "#dff" })
|
||||||
|
// }, 25000);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }, 6000);
|
||||||
|
// },
|
||||||
|
// () => {
|
||||||
|
// if (localSettings.loreCount < 2) {
|
||||||
|
// localSettings.loreCount = 2
|
||||||
|
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
// }
|
||||||
|
// let delay = 6000
|
||||||
|
// setTimeout(() => { lore.miriam.text("Hey look! It's back at the weird level again!", true) }, delay);
|
||||||
|
// delay += 2500
|
||||||
|
// setTimeout(() => { lore.anand.text("oh Wow! Why does it keep making this level?", true) }, delay);
|
||||||
|
// delay += 2900
|
||||||
|
// setTimeout(() => { lore.miriam.text("I don't know, but last time it was in this room I think it understood us.", true) }, delay);
|
||||||
|
// delay += 4000
|
||||||
|
// setTimeout(() => { lore.miriam.text("Let's try talking to it again.", true) }, delay);
|
||||||
|
// delay += 2500
|
||||||
|
// setTimeout(() => { lore.miriam.text("hmmm, what should we say?", true) }, delay);
|
||||||
|
// delay += 2500
|
||||||
|
// setTimeout(() => { lore.anand.text("I'm still not convinced it understands. We need a test.", true) }, delay);
|
||||||
|
// delay += 4000
|
||||||
|
// setTimeout(() => { lore.miriam.text("Hey bot!!!", true) }, delay);
|
||||||
|
// delay += 1300
|
||||||
|
// setTimeout(() => { lore.miriam.text("If you can understand me crouch", true) }, delay);
|
||||||
|
// delay += 1500
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// setTimeout(() => {
|
||||||
|
// function cycle() {
|
||||||
|
// if (input.down) {
|
||||||
|
// let delay = 500 //reset delay time
|
||||||
|
// setTimeout(() => { lore.miriam.text("Look, It did it! It crouched.", true) }, delay);
|
||||||
|
// delay += 2000
|
||||||
|
// setTimeout(() => { lore.anand.text("Amazing! It can understand us...", true) }, delay);
|
||||||
|
// delay += 2700
|
||||||
|
// setTimeout(() => { lore.miriam.text("It's Alive... Or it just crouched randomly.", true) }, delay);
|
||||||
|
// delay += 2800
|
||||||
|
// setTimeout(() => { lore.miriam.text("Hey bot! Can you crouch again?", true) }, delay);
|
||||||
|
// delay += 2000
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// setTimeout(() => {
|
||||||
|
// function cycle() {
|
||||||
|
// if (input.down) {
|
||||||
|
// let delay = 500 //reset delay time
|
||||||
|
// setTimeout(() => { lore.miriam.text("It is Alive!!! ... hehehehehe ahahahahahah ehehehehe ahahahah", true) }, delay);
|
||||||
|
// delay += 3500
|
||||||
|
// setTimeout(() => { lore.anand.text("OK...", true) }, delay);
|
||||||
|
// delay += 2700
|
||||||
|
// setTimeout(() => { lore.anand.text("but seriously, this means that in this room it can monitor our audio, and it can understand us.", true) }, delay);
|
||||||
|
// delay += 6400
|
||||||
|
// setTimeout(() => { lore.anand.text("Anything we say could destabilize the project.", true) }, delay);
|
||||||
|
// delay += 4200
|
||||||
|
// setTimeout(() => { lore.miriam.text("Fine, Let's talk down stairs.", true) }, delay);
|
||||||
|
// delay += 3000
|
||||||
|
// setTimeout(() => { lore.miriam.text("Bye bye little bot.", true) }, delay);
|
||||||
|
// delay += 2000
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// } else {
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// }, delay);
|
||||||
|
// } else {
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// requestAnimationFrame(cycle);
|
||||||
|
// }, delay);
|
||||||
|
// },
|
||||||
|
// () => {
|
||||||
|
// let delay = 6000
|
||||||
|
// setTimeout(() => { lore.miriam.text("I've never seen it generate this level before.", true) }, delay);
|
||||||
|
// delay += 2700
|
||||||
|
// setTimeout(() => { lore.anand.text("Wow. Just a platform.", true) }, delay);
|
||||||
|
// delay += 2200
|
||||||
|
// setTimeout(() => { lore.miriam.text("And that thing...", true) }, delay);
|
||||||
|
// delay += 1500
|
||||||
|
// setTimeout(() => { lore.anand.text("Weird", true) }, delay);
|
||||||
|
// delay += 1500
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// delay += 1000
|
||||||
|
// setTimeout(() => { lore.anand.text("Maybe it's trapped.", true) }, delay);
|
||||||
|
// delay += 2300
|
||||||
|
// setTimeout(() => { lore.unlockTesting() }, delay);
|
||||||
|
// setTimeout(() => { lore.miriam.text('Hey little bot! Just press "T" to enter testing mode and "U" to go to the next level.', true) }, delay);
|
||||||
|
// delay += 5400
|
||||||
|
// setTimeout(() => { lore.anand.text("I don't think it's connected to the audio input, and I'm sure it can't understand what you're saying.", true) }, delay);
|
||||||
|
// delay += 5300
|
||||||
|
// setTimeout(() => { lore.miriam.text("ha hahahaha. I know, but it does seem to be getting smarter.", true) }, delay);
|
||||||
|
// delay += 3700
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// delay += 25000
|
||||||
|
// setTimeout(() => {
|
||||||
|
// if (!simulation.isCheating) {
|
||||||
|
// lore.miriam.text("Poor thing... I hope it figures out how to escape.", true)
|
||||||
|
// delay += 3500
|
||||||
|
// setTimeout(() => { lore.talkingColor = "#dff" }, delay); //set color of graphic on level.null when no one is talking
|
||||||
|
// }
|
||||||
|
// }, delay);
|
||||||
|
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
|
unlockTesting() {
|
||||||
|
if (localSettings.loreCount < 1) localSettings.loreCount = 1
|
||||||
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
document.getElementById("control-testing").style.visibility = (localSettings.loreCount === 0) ? "hidden" : "visible"
|
||||||
|
document.getElementById("experiment-button").style.visibility = (localSettings.loreCount === 0) ? "hidden" : "visible"
|
||||||
|
simulation.makeTextLog(`lore.unlockTesting()`, Infinity);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ const m = {
|
|||||||
setMaxHealth() {
|
setMaxHealth() {
|
||||||
m.maxHealth = m.baseHealth + tech.extraMaxHealth + tech.isFallingDamage //+ tech.bonusHealth
|
m.maxHealth = m.baseHealth + tech.extraMaxHealth + tech.isFallingDamage //+ tech.bonusHealth
|
||||||
document.getElementById("health-bg").style.width = `${Math.floor(300*m.maxHealth)}px`
|
document.getElementById("health-bg").style.width = `${Math.floor(300*m.maxHealth)}px`
|
||||||
simulation.makeTextLog(`<span class='color-var'>m</span>.<span class='color-h'>maxHealth</span> <span class='color-symbol'>=</span> ${m.maxHealth.toFixed(2)}`)
|
simulation.makeTextLog(`<span class='color-var'>m</span>.<span class='color-h'>maxHealth</span> <span class='color-symbol'>=</span> ${m.maxHealth.toFixed(3)}`)
|
||||||
if (m.health > m.maxHealth) m.health = m.maxHealth;
|
if (m.health > m.maxHealth) m.health = m.maxHealth;
|
||||||
m.displayHealth();
|
m.displayHealth();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -145,10 +145,21 @@ const powerUps = {
|
|||||||
},
|
},
|
||||||
showDraft() {
|
showDraft() {
|
||||||
// document.getElementById("choose-grid").style.gridTemplateColumns = "repeat(2, minmax(370px, 1fr))"
|
// document.getElementById("choose-grid").style.gridTemplateColumns = "repeat(2, minmax(370px, 1fr))"
|
||||||
document.getElementById("choose-grid").style.display = "grid"
|
// document.getElementById("choose-background").style.display = "inline"
|
||||||
document.getElementById("choose-background").style.display = "inline"
|
document.getElementById("choose-background").style.visibility = "visible"
|
||||||
|
document.getElementById("choose-background").style.opacity = "0.6"
|
||||||
|
// document.getElementById("choose-grid").style.display = "grid"
|
||||||
|
document.getElementById("choose-grid").style.transitionDuration = "0.25s";
|
||||||
|
document.getElementById("choose-grid").style.visibility = "visible"
|
||||||
|
document.getElementById("choose-grid").style.opacity = "1"
|
||||||
|
//disable clicking for 1/2 a second to prevent mistake clicks
|
||||||
|
document.getElementById("choose-grid").style.pointerEvents = "none";
|
||||||
|
setTimeout(() => {
|
||||||
|
document.getElementById("choose-grid").style.pointerEvents = "auto";
|
||||||
|
document.body.style.cursor = "auto";
|
||||||
|
document.getElementById("choose-grid").style.transitionDuration = "0s";
|
||||||
|
}, 500);
|
||||||
|
|
||||||
document.body.style.cursor = "auto";
|
|
||||||
if (tech.isExtraChoice) {
|
if (tech.isExtraChoice) {
|
||||||
document.body.style.overflowY = "scroll";
|
document.body.style.overflowY = "scroll";
|
||||||
document.body.style.overflowX = "hidden";
|
document.body.style.overflowX = "hidden";
|
||||||
@@ -187,8 +198,13 @@ const powerUps = {
|
|||||||
if (tech.isAnsatz && powerUps.research.count === 0) {
|
if (tech.isAnsatz && powerUps.research.count === 0) {
|
||||||
for (let i = 0; i < 2; i++) powerUps.spawn(m.pos.x + 40 * (Math.random() - 0.5), m.pos.y + 40 * (Math.random() - 0.5), "research", false);
|
for (let i = 0; i < 2; i++) powerUps.spawn(m.pos.x + 40 * (Math.random() - 0.5), m.pos.y + 40 * (Math.random() - 0.5), "research", false);
|
||||||
}
|
}
|
||||||
document.getElementById("choose-grid").style.display = "none"
|
// document.getElementById("choose-grid").style.display = "none"
|
||||||
document.getElementById("choose-background").style.display = "none"
|
document.getElementById("choose-grid").style.visibility = "hidden"
|
||||||
|
document.getElementById("choose-grid").style.opacity = "0"
|
||||||
|
// document.getElementById("choose-background").style.display = "none"
|
||||||
|
document.getElementById("choose-background").style.visibility = "hidden"
|
||||||
|
document.getElementById("choose-background").style.opacity = "0"
|
||||||
|
|
||||||
document.body.style.cursor = "none";
|
document.body.style.cursor = "none";
|
||||||
document.body.style.overflow = "hidden"
|
document.body.style.overflow = "hidden"
|
||||||
simulation.paused = false;
|
simulation.paused = false;
|
||||||
@@ -283,30 +299,56 @@ const powerUps = {
|
|||||||
return tech.largerHeals * (size / 40 / Math.sqrt(tech.largerHeals) / (simulation.healScale ** 0.25)) ** 2 //heal scale is undone here because heal scale is properly affected on m.addHealth()
|
return tech.largerHeals * (size / 40 / Math.sqrt(tech.largerHeals) / (simulation.healScale ** 0.25)) ** 2 //heal scale is undone here because heal scale is properly affected on m.addHealth()
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
|
// if (!tech.isEnergyHealth && m.alive) {
|
||||||
|
// const heal = powerUps.heal.calculateHeal(this.size)
|
||||||
|
// if (heal > 0) {
|
||||||
|
// if (tech.isOverHeal && m.health === m.maxHealth) { //tech quenching
|
||||||
|
// m.damage(heal * simulation.healScale);
|
||||||
|
// //draw damage
|
||||||
|
// simulation.drawList.push({ //add dmg to draw queue
|
||||||
|
// x: m.pos.x,
|
||||||
|
// y: m.pos.y,
|
||||||
|
// radius: heal * 500 * simulation.healScale,
|
||||||
|
// color: simulation.mobDmgColor,
|
||||||
|
// time: simulation.drawTime
|
||||||
|
// });
|
||||||
|
// tech.extraMaxHealth += heal * simulation.healScale //increase max health
|
||||||
|
// m.setMaxHealth();
|
||||||
|
// } else {
|
||||||
|
// const healOutput = Math.min(m.maxHealth - m.health, heal) * simulation.healScale
|
||||||
|
// m.addHealth(heal);
|
||||||
|
// simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>+=</span> ${(healOutput).toFixed(3)}`) // <br>${m.health.toFixed(3)}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
if (!tech.isEnergyHealth && m.alive) {
|
if (!tech.isEnergyHealth && m.alive) {
|
||||||
const heal = powerUps.heal.calculateHeal(this.size)
|
const heal = powerUps.heal.calculateHeal(this.size)
|
||||||
if (heal > 0) {
|
if (heal > 0) {
|
||||||
if (tech.isOverHeal && m.health === m.maxHealth) { //tech quenching
|
const overHeal = m.health + heal * simulation.healScale - m.maxHealth //used with tech.isOverHeal
|
||||||
if (m.immuneCycle < m.cycle) {
|
|
||||||
m.damage(heal * simulation.healScale);
|
const healOutput = Math.min(m.maxHealth - m.health, heal) * simulation.healScale
|
||||||
//draw damage
|
m.addHealth(heal);
|
||||||
simulation.drawList.push({ //add dmg to draw queue
|
simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>+=</span> ${(healOutput).toFixed(3)}`) // <br>${m.health.toFixed(3)}
|
||||||
x: m.pos.x,
|
|
||||||
y: m.pos.y,
|
if (tech.isOverHeal && overHeal > 0) { //tech quenching
|
||||||
radius: heal * 500 * simulation.healScale,
|
const scaledOverHeal = overHeal * 0.8
|
||||||
color: simulation.mobDmgColor,
|
m.damage(scaledOverHeal);
|
||||||
time: simulation.drawTime
|
simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>-=</span> ${(scaledOverHeal).toFixed(3)}`) // <br>${m.health.toFixed(3)}
|
||||||
});
|
|
||||||
}
|
//draw damage
|
||||||
tech.extraMaxHealth += heal * simulation.healScale //increase max health
|
simulation.drawList.push({ //add dmg to draw queue
|
||||||
|
x: m.pos.x,
|
||||||
|
y: m.pos.y,
|
||||||
|
radius: scaledOverHeal * 500 * simulation.healScale,
|
||||||
|
color: simulation.mobDmgColor,
|
||||||
|
time: simulation.drawTime
|
||||||
|
});
|
||||||
|
tech.extraMaxHealth += scaledOverHeal * simulation.healScale //increase max health
|
||||||
m.setMaxHealth();
|
m.setMaxHealth();
|
||||||
} else {
|
|
||||||
const healOutput = Math.min(m.maxHealth - m.health, heal) * simulation.healScale
|
|
||||||
m.addHealth(heal);
|
|
||||||
simulation.makeTextLog(`<span class='color-var'>m</span>.health <span class='color-symbol'>+=</span> ${(healOutput).toFixed(3)}`) // <br>${m.health.toFixed(3)}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tech.healGiveMaxEnergy) {
|
if (tech.healGiveMaxEnergy) {
|
||||||
tech.healMaxEnergyBonus += 0.06
|
tech.healMaxEnergyBonus += 0.06
|
||||||
m.setMaxEnergy();
|
m.setMaxEnergy();
|
||||||
@@ -407,7 +449,7 @@ const powerUps = {
|
|||||||
powerUps.field.choiceLog.push(choice3)
|
powerUps.field.choiceLog.push(choice3)
|
||||||
|
|
||||||
if (tech.isJunkResearch) {
|
if (tech.isJunkResearch) {
|
||||||
tech.junkResearchNumber = Math.ceil(5 * Math.random())
|
tech.junkResearchNumber = Math.floor(5 * Math.random())
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.research.use('field')"><div class="grid-title"> <span style="position:relative;">`
|
text += `<div class="choose-grid-module" onclick="powerUps.research.use('field')"><div class="grid-title"> <span style="position:relative;">`
|
||||||
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
||||||
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
||||||
@@ -520,7 +562,7 @@ const powerUps = {
|
|||||||
// if (powerUps.research.count) text += `<div class="choose-grid-module" onclick="powerUps.research.use('tech')"><div class="grid-title"><div class="circle-grid research"></div> research <span class="research-select">${powerUps.research.count}</span></div></div>`
|
// if (powerUps.research.count) text += `<div class="choose-grid-module" onclick="powerUps.research.use('tech')"><div class="grid-title"><div class="circle-grid research"></div> research <span class="research-select">${powerUps.research.count}</span></div></div>`
|
||||||
|
|
||||||
if (tech.isJunkResearch) {
|
if (tech.isJunkResearch) {
|
||||||
tech.junkResearchNumber = Math.ceil(5 * Math.random())
|
tech.junkResearchNumber = Math.floor(5 * Math.random())
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.research.use('tech')"><div class="grid-title"> <span style="position:relative;">`
|
text += `<div class="choose-grid-module" onclick="powerUps.research.use('tech')"><div class="grid-title"> <span style="position:relative;">`
|
||||||
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
||||||
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
||||||
@@ -612,7 +654,7 @@ const powerUps = {
|
|||||||
// if (powerUps.research.count) text += `<div class="choose-grid-module" onclick="powerUps.research.use('gun')"><div class="grid-title"><div class="circle-grid research"></div> research <span class="research-select">${powerUps.research.count}</span></div></div>`
|
// if (powerUps.research.count) text += `<div class="choose-grid-module" onclick="powerUps.research.use('gun')"><div class="grid-title"><div class="circle-grid research"></div> research <span class="research-select">${powerUps.research.count}</span></div></div>`
|
||||||
|
|
||||||
if (tech.isJunkResearch) {
|
if (tech.isJunkResearch) {
|
||||||
tech.junkResearchNumber = Math.ceil(5 * Math.random())
|
tech.junkResearchNumber = Math.floor(5 * Math.random())
|
||||||
text += `<div class="choose-grid-module" onclick="powerUps.research.use('gun')"><div class="grid-title"> <span style="position:relative;">`
|
text += `<div class="choose-grid-module" onclick="powerUps.research.use('gun')"><div class="grid-title"> <span style="position:relative;">`
|
||||||
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
for (let i = 0; i < tech.junkResearchNumber; i++) text += `<div class="circle-grid junk" style="position:absolute; top:0; left:${15*i}px ;opacity:0.8; border: 1px #fff solid;"></div>`
|
||||||
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
text += `</span> <span class='research-select'>pseudoscience</span></div></div>`
|
||||||
|
|||||||
@@ -469,7 +469,9 @@ const simulation = {
|
|||||||
document.getElementById("splash").onclick = function() {
|
document.getElementById("splash").onclick = function() {
|
||||||
simulation.startGame();
|
simulation.startGame();
|
||||||
};
|
};
|
||||||
document.getElementById("choose-grid").style.display = "none"
|
// document.getElementById("choose-grid").style.display = "none"
|
||||||
|
document.getElementById("choose-grid").style.visibility = "hidden"
|
||||||
|
document.getElementById("choose-grid").style.opacity = "0"
|
||||||
document.getElementById("info").style.display = "inline";
|
document.getElementById("info").style.display = "inline";
|
||||||
document.getElementById("experiment-button").style.display = "inline"
|
document.getElementById("experiment-button").style.display = "inline"
|
||||||
document.getElementById("experiment-grid").style.display = "none"
|
document.getElementById("experiment-grid").style.display = "none"
|
||||||
@@ -489,7 +491,9 @@ const simulation = {
|
|||||||
document.body.style.overflow = "hidden"
|
document.body.style.overflow = "hidden"
|
||||||
}
|
}
|
||||||
simulation.onTitlePage = false;
|
simulation.onTitlePage = false;
|
||||||
document.getElementById("choose-grid").style.display = "none"
|
// document.getElementById("choose-grid").style.display = "none"
|
||||||
|
document.getElementById("choose-grid").style.visibility = "hidden"
|
||||||
|
document.getElementById("choose-grid").style.opacity = "0"
|
||||||
document.getElementById("experiment-grid").style.display = "none"
|
document.getElementById("experiment-grid").style.display = "none"
|
||||||
document.getElementById("info").style.display = "none";
|
document.getElementById("info").style.display = "none";
|
||||||
document.getElementById("experiment-button").style.display = "none";
|
document.getElementById("experiment-button").style.display = "none";
|
||||||
|
|||||||
30
js/tech.js
30
js/tech.js
@@ -2504,7 +2504,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "quenching",
|
name: "quenching",
|
||||||
description: "if you're at full <strong class='color-h'>health</strong> heal power ups do <strong class='color-harm'>harm</strong><br>but they also increase your <strong>maximum</strong> <strong class='color-h'>health</strong>",
|
description: "over healing from <strong class='color-h'>heal</strong> power ups does <strong class='color-harm'>harm</strong><br>but it also increase your <strong>maximum</strong> <strong class='color-h'>health</strong>",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
frequency: 2,
|
frequency: 2,
|
||||||
@@ -2522,7 +2522,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "negentropy",
|
name: "negentropy",
|
||||||
description: `at the start of each <strong>level</strong><br>spawn a <strong class='color-h'>heal</strong> for every <strong>25</strong> missing health`,
|
description: `at the start of each <strong>level</strong><br>spawn a <strong class='color-h'>heal</strong> for every <strong>22</strong> missing health`,
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
frequency: 1,
|
frequency: 1,
|
||||||
@@ -2560,7 +2560,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "maintenance",
|
name: "maintenance",
|
||||||
description: "</strong>double</strong> the <strong class='flicker'>frequency</strong> of finding <strong class='color-h'>healing</strong> <strong class='color-m'>tech</strong><br>spawn <strong>15</strong> <strong class='color-h'>heals</strong>",
|
description: "</strong>double</strong> the <strong class='flicker'>frequency</strong> of finding <strong class='color-h'>healing</strong> <strong class='color-m'>tech</strong><br>spawn <strong>14</strong> <strong class='color-h'>heals</strong>",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
frequency: 1,
|
frequency: 1,
|
||||||
@@ -2572,7 +2572,7 @@
|
|||||||
},
|
},
|
||||||
requires: "health < 70%, not ergodicity",
|
requires: "health < 70%, not ergodicity",
|
||||||
effect() {
|
effect() {
|
||||||
for (let i = 0; i < 15; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "heal");
|
for (let i = 0; i < 14; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "heal");
|
||||||
for (let i = 0, len = tech.tech.length; i < len; i++) {
|
for (let i = 0, len = tech.tech.length; i < len; i++) {
|
||||||
if (tech.tech[i].isHealTech) tech.tech[i].frequency *= 2
|
if (tech.tech[i].isHealTech) tech.tech[i].frequency *= 2
|
||||||
}
|
}
|
||||||
@@ -2634,9 +2634,9 @@
|
|||||||
frequency: 4,
|
frequency: 4,
|
||||||
frequencyDefault: 4,
|
frequencyDefault: 4,
|
||||||
allowed() {
|
allowed() {
|
||||||
return !tech.isSwitchReality && !tech.isResearchReality && tech.isDeathAvoid && !tech.isCollisionRealitySwitch
|
return tech.isDeathAvoid
|
||||||
},
|
},
|
||||||
requires: "anthropic principle, not many-worlds, Ψ(t) collapse, non-unitary",
|
requires: "anthropic principle",
|
||||||
effect() {
|
effect() {
|
||||||
tech.isImmortal = true;
|
tech.isImmortal = true;
|
||||||
},
|
},
|
||||||
@@ -2652,9 +2652,9 @@
|
|||||||
frequency: 1,
|
frequency: 1,
|
||||||
frequencyDefault: 1,
|
frequencyDefault: 1,
|
||||||
allowed() {
|
allowed() {
|
||||||
return !tech.isImmortal && !tech.isResearchReality && level.onLevel < 6 && !tech.isCollisionRealitySwitch
|
return !tech.isResearchReality && level.onLevel < 6 && !tech.isCollisionRealitySwitch
|
||||||
},
|
},
|
||||||
requires: "before level 6, not quantum immortality, Ψ(t) collapse, non-unitary",
|
requires: "before level 6, Ψ(t) collapse, non-unitary",
|
||||||
effect() {
|
effect() {
|
||||||
tech.isSwitchReality = true;
|
tech.isSwitchReality = true;
|
||||||
},
|
},
|
||||||
@@ -2670,9 +2670,9 @@
|
|||||||
frequency: 1,
|
frequency: 1,
|
||||||
frequencyDefault: 1,
|
frequencyDefault: 1,
|
||||||
allowed() {
|
allowed() {
|
||||||
return !tech.isImmortal && !tech.isResearchReality && !tech.isSwitchReality
|
return !tech.isResearchReality && !tech.isSwitchReality
|
||||||
},
|
},
|
||||||
requires: "not quantum immortality, Ψ(t) collapse, many-worlds",
|
requires: "Ψ(t) collapse, many-worlds",
|
||||||
effect() {
|
effect() {
|
||||||
tech.isCollisionRealitySwitch = true;
|
tech.isCollisionRealitySwitch = true;
|
||||||
level.difficultyDecrease(simulation.difficultyMode * 2)
|
level.difficultyDecrease(simulation.difficultyMode * 2)
|
||||||
@@ -2692,9 +2692,9 @@
|
|||||||
frequency: 1,
|
frequency: 1,
|
||||||
frequencyDefault: 1,
|
frequencyDefault: 1,
|
||||||
allowed() {
|
allowed() {
|
||||||
return !tech.isImmortal && !tech.isSwitchReality && !tech.isCollisionRealitySwitch
|
return !tech.isSwitchReality && !tech.isCollisionRealitySwitch
|
||||||
},
|
},
|
||||||
requires: "not quantum immortality, many-worlds, non-unitary",
|
requires: "many-worlds, non-unitary",
|
||||||
effect() {
|
effect() {
|
||||||
tech.isResearchReality = true;
|
tech.isResearchReality = true;
|
||||||
for (let i = 0; i < 16; i++) powerUps.spawn(m.pos.x + Math.random() * 60, m.pos.y + Math.random() * 60, "research", false);
|
for (let i = 0; i < 16; i++) powerUps.spawn(m.pos.x + Math.random() * 60, m.pos.y + Math.random() * 60, "research", false);
|
||||||
@@ -2801,7 +2801,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pseudoscience",
|
name: "pseudoscience",
|
||||||
description: "renewing power up choices costs no <strong class='color-r'>research</strong><br>but adds <strong>1-5</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool",
|
description: "resetting power up choices costs no <strong class='color-r'>research</strong><br>but adds <strong>0-4</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
frequency: 1,
|
frequency: 1,
|
||||||
@@ -6936,7 +6936,7 @@
|
|||||||
remove() {}
|
remove() {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "quantum hole",
|
name: "quantum black hole",
|
||||||
description: "use your <strong class='color-f'>energy</strong> and <strong>1</strong> <strong class='color-r'>research</strong> to <strong>spawn</strong><br>inside the event horizon of a huge <strong>black hole</strong>",
|
description: "use your <strong class='color-f'>energy</strong> and <strong>1</strong> <strong class='color-r'>research</strong> to <strong>spawn</strong><br>inside the event horizon of a huge <strong>black hole</strong>",
|
||||||
maxCount: 9,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
@@ -6950,7 +6950,7 @@
|
|||||||
requires: "at least 1 research",
|
requires: "at least 1 research",
|
||||||
effect() {
|
effect() {
|
||||||
m.energy = 0
|
m.energy = 0
|
||||||
spawn.suckerBoss(m.pos.x, m.pos.y - 1000)
|
spawn.suckerBoss(m.pos.x, m.pos.y - 700)
|
||||||
powerUps.research.changeRerolls(-1)
|
powerUps.research.changeRerolls(-1)
|
||||||
simulation.makeTextLog(`<span class='color-var'>m</span>.<span class='color-r'>research</span> <span class='color-symbol'>--</span><br>${powerUps.research.count}`)
|
simulation.makeTextLog(`<span class='color-var'>m</span>.<span class='color-r'>research</span> <span class='color-symbol'>--</span><br>${powerUps.research.count}`)
|
||||||
},
|
},
|
||||||
|
|||||||
96
lib/OLD_matter.min.js
vendored
96
lib/OLD_matter.min.js
vendored
@@ -1,96 +0,0 @@
|
|||||||
/**
|
|
||||||
* matter-js 0.14.2 by @liabru 2018-06-11
|
|
||||||
* http://brm.io/matter-js/
|
|
||||||
* License MIT
|
|
||||||
*/
|
|
||||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function(){function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}return e}()({1:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){o._inertiaScale=4,
|
|
||||||
o._nextCollidingGroupId=1,o._nextNonCollidingGroupId=-1,o._nextCategory=1,o.create=function(t){var n={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0}},o=a.extend(n,t);return e(o,t),o},o.nextGroup=function(e){return e?o._nextNonCollidingGroupId--:o._nextCollidingGroupId++},o.nextCategory=function(){return o._nextCategory=o._nextCategory<<1,o._nextCategory};var e=function(e,t){t=t||{},o.set(e,{bounds:e.bounds||l.create(e.vertices),
|
|
||||||
positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),o.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||"#000",e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};o.set=function(e,t,n){var i;"string"==typeof t&&(i=t,t={},t[i]=n);for(i in t)if(n=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":o.setStatic(e,n);break;case"isSleeping":s.set(e,n);break;case"mass":o.setMass(e,n);break;case"density":o.setDensity(e,n)
|
|
||||||
;break;case"inertia":o.setInertia(e,n);break;case"vertices":o.setVertices(e,n);break;case"position":o.setPosition(e,n);break;case"angle":o.setAngle(e,n);break;case"velocity":o.setVelocity(e,n);break;case"angularVelocity":o.setAngularVelocity(e,n);break;case"parts":o.setParts(e,n);break;default:e[i]=n}},o.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var o=e.parts[n];o.isStatic=t,t?(o._original={restitution:o.restitution,friction:o.friction,mass:o.mass,inertia:o.inertia,density:o.density,inverseMass:o.inverseMass,inverseInertia:o.inverseInertia},o.restitution=0,o.friction=1,o.mass=o.inertia=o.density=1/0,o.inverseMass=o.inverseInertia=0,o.positionPrev.x=o.position.x,o.positionPrev.y=o.position.y,o.anglePrev=o.angle,o.angularVelocity=0,o.speed=0,o.angularSpeed=0,o.motion=0):o._original&&(o.restitution=o._original.restitution,o.friction=o._original.friction,o.mass=o._original.mass,o.inertia=o._original.inertia,o.density=o._original.density,
|
|
||||||
o.inverseMass=o._original.inverseMass,o.inverseInertia=o._original.inverseInertia,delete o._original)}},o.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},o.setDensity=function(e,t){o.setMass(e,t*e.area),e.density=t},o.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},o.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),o.setMass(e,e.density*e.area);var n=i.centre(e.vertices);i.translate(e.vertices,n,-1),o.setInertia(e,o._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},o.setParts=function(e,t,n){var r;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(n=void 0===n||n){var a=[]
|
|
||||||
;for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);o.setVertices(e,l),i.translate(e.vertices,c)}var d=o._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,o.setMass(e,d.mass),o.setInertia(e,d.inertia),o.setPosition(e,d.centre)}},o.setPosition=function(e,t){var n=r.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.position.x+=n.x,s.position.y+=n.y,i.translate(s.vertices,n),l.update(s.bounds,s.vertices,e.velocity)}},o.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.angle+=n,i.rotate(s.vertices,n,e.position),c.rotate(s.axes,n),l.update(s.bounds,s.vertices,e.velocity),o>0&&r.rotateAbout(s.position,n,e.position,s.position)}},o.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,
|
|
||||||
e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},o.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},o.translate=function(e,t){o.setPosition(e,r.add(e.position,t))},o.rotate=function(e,t,n){if(n){var i=Math.cos(t),r=Math.sin(t),s=e.position.x-n.x,a=e.position.y-n.y;o.setPosition(e,{x:n.x+(s*i-a*r),y:n.y+(s*r+a*i)}),o.setAngle(e,e.angle+t)}else o.setAngle(e,e.angle+t)},o.scale=function(e,t,n,r){var s=0,a=0;r=r||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];i.scale(u.vertices,t,n,r),u.axes=c.fromVertices(u.vertices),u.area=i.area(u.vertices),o.setMass(u,e.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),o.setInertia(u,o._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(s+=u.area,a+=u.inertia),u.position.x=r.x+(u.position.x-r.x)*t,u.position.y=r.y+(u.position.y-r.y)*n,l.update(u.bounds,u.vertices,e.velocity)
|
|
||||||
}e.parts.length>1&&(e.area=s,e.isStatic||(o.setMass(e,e.density*s),o.setInertia(e,a))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},o.update=function(e,t,n,o){var s=Math.pow(t*n*e.timeScale,2),a=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*o+e.force.x/e.mass*s,e.velocity.y=u*a*o+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*o+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),
|
|
||||||
p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},o.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var o={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=o.x*n.y-o.y*n.x},o._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var o=e.parts[n],i=o.mass!==1/0?o.mass:1;t.mass+=i,t.area+=o.area,t.inertia+=o.inertia,t.centre=r.add(t.centre,r.mult(o.position,i))}return t.centre=r.div(t.centre,t.mass),t}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31}],2:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Events"),r=e("../core/Common"),s=e("../geometry/Bounds"),a=e("./Body");!function(){o.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],
|
|
||||||
label:"Composite",plugin:{}},e)},o.setModified=function(e,t,n,i){if(e.isModified=t,n&&e.parent&&o.setModified(e.parent,t,n,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];o.setModified(s,t,n,i)}},o.add=function(e,t){var n=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<n.length;s++){var a=n[s];switch(a.type){case"body":if(a.parent!==a){r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}o.addBody(e,a);break;case"constraint":o.addConstraint(e,a);break;case"composite":o.addComposite(e,a);break;case"mouseConstraint":o.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},o.remove=function(e,t,n){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":o.removeBody(e,a,n);break;case"constraint":o.removeConstraint(e,a,n);break;case"composite":o.removeComposite(e,a,n);break;case"mouseConstraint":
|
|
||||||
o.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},o.addComposite=function(e,t){return e.composites.push(t),t.parent=e,o.setModified(e,!0,!0,!1),e},o.removeComposite=function(e,t,n){var i=r.indexOf(e.composites,t);if(-1!==i&&(o.removeCompositeAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeComposite(e.composites[s],t,!0);return e},o.removeCompositeAt=function(e,t){return e.composites.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addBody=function(e,t){return e.bodies.push(t),o.setModified(e,!0,!0,!1),e},o.removeBody=function(e,t,n){var i=r.indexOf(e.bodies,t);if(-1!==i&&(o.removeBodyAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeBody(e.composites[s],t,!0);return e},o.removeBodyAt=function(e,t){return e.bodies.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addConstraint=function(e,t){return e.constraints.push(t),o.setModified(e,!0,!0,!1),e},o.removeConstraint=function(e,t,n){
|
|
||||||
var i=r.indexOf(e.constraints,t);if(-1!==i&&o.removeConstraintAt(e,i),n)for(var s=0;s<e.composites.length;s++)o.removeConstraint(e.composites[s],t,!0);return e},o.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),o.setModified(e,!0,!0,!1),e},o.clear=function(e,t,n){if(n)for(var i=0;i<e.composites.length;i++)o.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,o.setModified(e,!0,!0,!1),e},o.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(o.allBodies(e.composites[n]));return t},o.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(o.allConstraints(e.composites[n]));return t},o.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(o.allComposites(e.composites[n]));return t},o.get=function(e,t,n){var i,r;switch(n){case"body":
|
|
||||||
i=o.allBodies(e);break;case"constraint":i=o.allConstraints(e);break;case"composite":i=o.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},o.move=function(e,t,n){return o.remove(e,t),o.add(n,t),e},o.rebase=function(e){for(var t=o.allBodies(e).concat(o.allConstraints(e)).concat(o.allComposites(e)),n=0;n<t.length;n++)t[n].id=r.nextId();return o.setModified(e,!0,!0,!1),e},o.translate=function(e,t,n){for(var i=n?o.allBodies(e):e.bodies,r=0;r<i.length;r++)a.translate(i[r],t);return o.setModified(e,!0,!0,!1),e},o.rotate=function(e,t,n,i){for(var r=Math.cos(t),s=Math.sin(t),l=i?o.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-n.x,p=d.position.y-n.y;a.setPosition(d,{x:n.x+(u*r-p*s),y:n.y+(u*s+p*r)}),a.rotate(d,t)}return o.setModified(e,!0,!0,!1),e},o.scale=function(e,t,n,i,r){for(var s=r?o.allBodies(e):e.bodies,l=0;l<s.length;l++){var c=s[l],d=c.position.x-i.x,u=c.position.y-i.y
|
|
||||||
;a.setPosition(c,{x:i.x+d*t,y:i.y+u*n}),a.scale(c,t,n)}return o.setModified(e,!0,!0,!1),e},o.bounds=function(e){for(var t=o.allBodies(e),n=[],i=0;i<t.length;i+=1){var r=t[i];n.push(r.bounds.min,r.bounds.max)}return s.create(n)}}()},{"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"./Body":1}],3:[function(e,t,n){var o={};t.exports=o;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){o.create=function(e){var t=i.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(t,n,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){return{id:o.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},o.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,n){var o={};t.exports=o;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){o.collisions=function(e,t){
|
|
||||||
for(var n=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&(o.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds)))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var m=d.parts[f];if(p===c&&m===d||s.overlaps(p.bounds,m.bounds)){var v,y=r.id(p,m),g=a[y];v=g&&g.isActive?g.collision:null;var x=i.collides(p,m,v);x.collided&&n.push(x)}}}return n},o.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}}()},{"../geometry/Bounds":26,"./Pair":7,"./SAT":11}],6:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){o.create=function(e){var t={controller:o,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},o.update=function(e,t,n,i){
|
|
||||||
var r,s,a,l,c,d=n.world,u=e.buckets,p=!1;for(r=0;r<t.length;r++){var f=t[r];if((!f.isSleeping||i)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var m=o._getRegion(e,f);if(!f.region||m.id!==f.region.id||i){f.region&&!i||(f.region=m);var v=o._regionUnion(m,f.region);for(s=v.startCol;s<=v.endCol;s++)for(a=v.startRow;a<=v.endRow;a++){c=o._getBucketId(s,a),l=u[c];var y=s>=m.startCol&&s<=m.endCol&&a>=m.startRow&&a<=m.endRow,g=s>=f.region.startCol&&s<=f.region.endCol&&a>=f.region.startRow&&a<=f.region.endRow;!y&&g&&g&&l&&o._bucketRemoveBody(e,l,f),(f.region===m||y&&!g||i)&&(l||(l=o._createBucket(u,c)),o._bucketAddBody(e,l,f))}f.region=m,p=!0}}}p&&(e.pairsList=o._createActivePairsList(e))},o.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},o._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow)
|
|
||||||
;return o._createRegion(n,i,r,s)},o._getRegion=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o._createRegion(i,r,s,a)},o._createRegion=function(e,t,n,o){return{id:e+","+t+","+n+","+o,startCol:e,endCol:t,startRow:n,endRow:o}},o._getBucketId=function(e,t){return"C"+e+"R"+t},o._createBucket=function(e,t){return e[t]=[]},o._bucketAddBody=function(e,t,n){for(var o=0;o<t.length;o++){var r=t[o];if(!(n.id===r.id||n.isStatic&&r.isStatic)){var s=i.id(n,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[n,r,1]}}t.push(n)},o._bucketRemoveBody=function(e,t,n){t.splice(s.indexOf(t,n),1);for(var o=0;o<t.length;o++){var r=t[o],a=i.id(n,r),l=e.pairs[a];l&&(l[2]-=1)}},o._createActivePairsList=function(e){var t,n,o=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)n=e.pairs[t[i]],n[2]>0?o.push(n):delete e.pairs[t[i]];return o}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],
|
|
||||||
7:[function(e,t,n){var o={};t.exports=o;var i=e("./Contact");!function(){o.create=function(e,t){var n=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:o.id(n,i),bodyA:n,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:n.isSensor||i.isSensor,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return o.update(a,e,t),a},o.update=function(e,t,n){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}
|
|
||||||
e.separation=t.depth,o.setActive(e,!0,n)}else!0===e.isActive&&o.setActive(e,!1,n)},o.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},o.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}}()},{"./Contact":4}],8:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("../core/Common");!function(){o._pairMaxIdleLife=1e3,o.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},o.update=function(e,t,n){var o,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,m=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)o=t[l],o.collided&&(s=i.id(o.bodyA,o.bodyB),m.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,o,n)):(a=i.create(o,n),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(m,a.id)&&(i.setActive(a,!1,n),p.push(a))},o.removeOld=function(e,t){
|
|
||||||
var n,i,r,s,a=e.list,l=e.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>o._pairMaxIdleLife&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},o.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){o.collides=function(e,t){for(var n=[],o=0;o<t.length;o++){var i=t[o];if(s.overlaps(i.bounds,e.bounds))for(var a=1===i.parts.length?0:1;a<i.parts.length;a++){var l=i.parts[a];if(s.overlaps(l.bounds,e.bounds)){var c=r.collides(l,e);if(c.collided){n.push(c);break}}}}return n},o.ray=function(e,t,n,r){r=r||1e-100
|
|
||||||
;for(var s=i.angle(t,n),l=i.magnitude(i.sub(t,n)),c=.5*(n.x+t.x),d=.5*(n.y+t.y),u=a.rectangle(c,d,l,r,{angle:s}),p=o.collides(u,e),f=0;f<p.length;f+=1){var m=p[f];m.body=m.bodyB=m.bodyA}return p},o.region=function(e,t,n){for(var o=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!n||!a&&n)&&o.push(r)}return o},o.point=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){n.push(i);break}}}return n}}()},{"../factory/Bodies":23,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"./SAT":11}],10:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){o._restingThresh=4,o._restingThreshTangent=6,o._positionDampen=.9,o._positionWarming=.8,o._frictionNormalMultiplier=5,o.preSolvePosition=function(e){
|
|
||||||
var t,n,o;for(t=0;t<e.length;t++)n=e[t],n.isActive&&(o=n.activeContacts.length,n.collision.parentA.totalContacts+=o,n.collision.parentB.totalContacts+=o)},o.solvePosition=function(e,t){var n,i,s,a,l,c,d,u,p,f=r._temp[0],m=r._temp[1],v=r._temp[2],y=r._temp[3];for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,m),v),y),i.separation=r.dot(c,d));for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=o._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=o._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},o.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t]
|
|
||||||
;if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var s=0;s<n.parts.length;s++){var l=n.parts[s];i.translate(l.vertices,n.positionImpulse),a.update(l.bounds,l.vertices,n.velocity),l.position.x+=n.positionImpulse.x,l.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,r.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=o._positionWarming,n.positionImpulse.y*=o._positionWarming)}}},o.preSolveVelocity=function(e){var t,n,o,i,s,a,l,c,d,u,p,f,m,v,y=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(o=e[t],o.isActive&&!o.isSensor)for(i=o.activeContacts,s=o.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,n=0;n<i.length;n++)u=i[n],p=u.vertex,f=u.normalImpulse,m=u.tangentImpulse,0===f&&0===m||(y.x=c.x*f+d.x*m,y.y=c.y*f+d.y*m,a.isStatic||a.isSleeping||(v=r.sub(p,a.position,g),a.positionPrev.x+=y.x*a.inverseMass,a.positionPrev.y+=y.y*a.inverseMass,
|
|
||||||
a.anglePrev+=r.cross(v,y)*a.inverseInertia),l.isStatic||l.isSleeping||(v=r.sub(p,l.position,g),l.positionPrev.x-=y.x*l.inverseMass,l.positionPrev.y-=y.y*l.inverseMass,l.anglePrev-=r.cross(v,y)*l.inverseInertia))},o.solveVelocity=function(e,t){for(var n=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive&&!f.isSensor){var m=f.collision,v=m.parentA,y=m.parentB,g=m.normal,x=m.tangent,h=f.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,y.angularVelocity=y.angle-y.anglePrev;for(var w=0;w<h.length;w++){
|
|
||||||
var S=h[w],C=S.vertex,A=r.sub(C,v.position,a),P=r.sub(C,y.position,l),B=r.add(v.velocity,r.mult(r.perp(A),v.angularVelocity),c),M=r.add(y.velocity,r.mult(r.perp(P),y.angularVelocity),d),k=r.sub(B,M,u),I=r.dot(g,k),_=r.dot(x,k),T=Math.abs(_),R=s.sign(_),V=(1+f.restitution)*I,E=s.clamp(f.separation+I,0,1)*o._frictionNormalMultiplier,L=_,F=1/0;T>f.friction*f.frictionStatic*E*n&&(F=T,L=s.clamp(f.friction*R*n,-F,F));var O=r.cross(A,g),q=r.cross(P,g),W=b/(v.inverseMass+y.inverseMass+v.inverseInertia*O*O+y.inverseInertia*q*q);if(V*=W,L*=W,I<0&&I*I>o._restingThresh*n)S.normalImpulse=0;else{var D=S.normalImpulse;S.normalImpulse=Math.min(S.normalImpulse+V,0),V=S.normalImpulse-D}if(_*_>o._restingThreshTangent*n)S.tangentImpulse=0;else{var N=S.tangentImpulse;S.tangentImpulse=s.clamp(S.tangentImpulse+L,-F,F),L=S.tangentImpulse-N}i.x=g.x*V+x.x*L,i.y=g.y*V+x.y*L,v.isStatic||v.isSleeping||(v.positionPrev.x+=i.x*v.inverseMass,v.positionPrev.y+=i.y*v.inverseMass,
|
|
||||||
v.anglePrev+=r.cross(A,i)*v.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=i.x*y.inverseMass,y.positionPrev.y-=i.y*y.inverseMass,y.anglePrev-=r.cross(P,i)*y.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],11:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){o.collides=function(e,t,n){var s,a,l,c,d=!1;if(n){var u=e.parent,p=t.parent,f=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&f<.2,c=n}else c={collided:!1,bodyA:e,bodyB:t};if(n&&d){var m=c.axisBody,v=m===e?t:e,y=[m.axes[n.axisNumber]];if(l=o._overlapAxes(m.vertices,v.vertices,y),c.reused=!0,l.overlap<=0)return c.collided=!1,c}else{if(s=o._overlapAxes(e.vertices,t.vertices,e.axes),s.overlap<=0)return c.collided=!1,c;if(a=o._overlapAxes(t.vertices,e.vertices,t.axes),a.overlap<=0)return c.collided=!1,c;s.overlap<a.overlap?(l=s,
|
|
||||||
c.axisBody=e):(l=a,c.axisBody=t),c.axisNumber=l.axisNumber}c.bodyA=e.id<t.id?e:t,c.bodyB=e.id<t.id?t:e,c.collided=!0,c.depth=l.overlap,c.parentA=c.bodyA.parent,c.parentB=c.bodyB.parent,e=c.bodyA,t=c.bodyB,r.dot(l.axis,r.sub(t.position,e.position))<0?c.normal={x:l.axis.x,y:l.axis.y}:c.normal={x:-l.axis.x,y:-l.axis.y},c.tangent=r.perp(c.normal),c.penetration=c.penetration||{},c.penetration.x=c.normal.x*c.depth,c.penetration.y=c.normal.y*c.depth;var g=o._findSupports(e,t,c.normal),x=[];if(i.contains(e.vertices,g[0])&&x.push(g[0]),i.contains(e.vertices,g[1])&&x.push(g[1]),x.length<2){var h=o._findSupports(t,e,r.neg(c.normal));i.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&i.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[g[0]]),c.supports=x,c},o._overlapAxes=function(e,t,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],o._projectToAxis(a,e,s),o._projectToAxis(l,t,s),
|
|
||||||
(i=Math.min(a.max-l.min,l.max-a.min))<=0)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},o._projectToAxis=function(e,t,n){for(var o=r.dot(t[0],n),i=o,s=1;s<t.length;s+=1){var a=r.dot(t[s],n);a>i?i=a:a<o&&(o=a)}e.min=o,e.max=i},o._findSupports=function(e,t,n){for(var o,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,(o=-r.dot(n,c))<l&&(l=o,s=i);return i=d[s.index-1>=0?s.index-1:d.length-1],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(n,c),a=i,i=d[(s.index+1)%d.length],c.x=i.x-u.x,c.y=i.y-u.y,o=-r.dot(n,c),o<l&&(a=i),[s,a]}}()},{"../geometry/Vector":28,"../geometry/Vertices":29}],12:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){o._warming=.4,o._torqueDampen=1,o._minLength=1e-6,o.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),
|
|
||||||
t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?r.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?r.add(t.bodyB.position,t.pointB):t.pointB,i=r.magnitude(r.sub(n,o));t.length=void 0!==t.length?t.length:i,t.id=t.id||c.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var s={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(s.type="pin",s.anchors=!1):t.stiffness<.9&&(s.type="spring"),t.render=c.extend(s,t.render),t},o.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],o=n.constraintImpulse;n.isStatic||0===o.x&&0===o.y&&0===o.angle||(n.position.x+=o.x,n.position.y+=o.y,n.angle+=o.angle)}},o.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){
|
|
||||||
var i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(r||s)&&o.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,r||s||o.solve(e[n],t)},o.solve=function(e,t){var n=e.bodyA,i=e.bodyB,s=e.pointA,a=e.pointB;if(n||i){n&&!n.isStatic&&(r.rotate(s,n.angle-e.angleA,s),e.angleA=n.angle),i&&!i.isStatic&&(r.rotate(a,i.angle-e.angleB,a),e.angleB=i.angle);var l=s,c=a;if(n&&(l=r.add(n.position,s)),i&&(c=r.add(i.position,a)),l&&c){var d=r.sub(l,c),u=r.magnitude(d);u<o._minLength&&(u=o._minLength);var p,f,m,v,y,g=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=r.mult(d,g*x),b=(n?n.inverseMass:0)+(i?i.inverseMass:0),w=(n?n.inverseInertia:0)+(i?i.inverseInertia:0),S=b+w;if(e.damping){var C=r.create();m=r.div(d,u),y=r.sub(i&&r.sub(i.position,i.positionPrev)||C,n&&r.sub(n.position,n.positionPrev)||C),v=r.dot(m,y)}n&&!n.isStatic&&(f=n.inverseMass/b,n.constraintImpulse.x-=h.x*f,
|
|
||||||
n.constraintImpulse.y-=h.y*f,n.position.x-=h.x*f,n.position.y-=h.y*f,e.damping&&(n.positionPrev.x-=e.damping*m.x*v*f,n.positionPrev.y-=e.damping*m.y*v*f),p=r.cross(s,h)/S*o._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),i&&!i.isStatic&&(f=i.inverseMass/b,i.constraintImpulse.x+=h.x*f,i.constraintImpulse.y+=h.y*f,i.position.x+=h.x*f,i.position.y+=h.y*f,e.damping&&(i.positionPrev.x+=e.damping*m.x*v*f,i.positionPrev.y+=e.damping*m.y*v*f),p=r.cross(a,h)/S*o._torqueDampen*i.inverseInertia*(1-e.angularStiffness),i.constraintImpulse.angle+=p,i.angle+=p)}}},o.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],c=n.constraintImpulse;if(!(n.isStatic||0===c.x&&0===c.y&&0===c.angle)){s.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];i.translate(u.vertices,c),d>0&&(u.position.x+=c.x,u.position.y+=c.y),0!==c.angle&&(i.rotate(u.vertices,c.angle,n.position),l.rotate(u.axes,c.angle),
|
|
||||||
d>0&&r.rotateAbout(u.position,c.angle,n.position,u.position)),a.update(u.bounds,u.vertices,n.velocity)}c.angle*=o._warming,c.x*=o._warming,c.y*=o._warming}}}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],13:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){o.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=s.create(e.render.canvas):t&&t.element?n=s.create(t.element):(n=s.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i=c.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,
|
|
||||||
render:{strokeStyle:"#90EE90",lineWidth:3}}),r={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:i,collisionFilter:{category:1,mask:4294967295,group:0}},l=u.extend(r,t);return a.on(e,"beforeUpdate",function(){var t=d.allBodies(e.world);o.update(l,t),o._triggerEvents(l)}),l},o.update=function(e,t){var n=e.mouse,o=e.constraint,s=e.body;if(0===n.button){if(o.bodyB)r.set(o.bodyB,!1),o.pointA=n.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,n.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,n.position)){o.pointA=n.position,o.bodyB=e.body=s,o.pointB={x:n.position.x-s.position.x,y:n.position.y-s.position.y},o.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:n,body:s});break}}}else o.bodyB=e.body=null,o.pointB=null,s&&a.trigger(e,"enddrag",{mouse:n,body:s})},o._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents
|
|
||||||
;n.mousemove&&a.trigger(e,"mousemove",{mouse:t}),n.mousedown&&a.trigger(e,"mousedown",{mouse:t}),n.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":19,"../core/Sleeping":22,"../geometry/Bounds":26,"../geometry/Vertices":29,"./Constraint":12}],14:[function(e,t,n){(function(n){var o={};t.exports=o,function(){o._nextId=0,o._seed=0,o._nowStartTime=+new Date,o.extend=function(e,t){var n,i;"boolean"==typeof t?(n=2,i=t):(n=1,i=!0);for(var r=n;r<arguments.length;r++){var s=arguments[r];if(s)for(var a in s)i&&s[a]&&s[a].constructor===Object?e[a]&&e[a].constructor!==Object?e[a]=s[a]:(e[a]=e[a]||{},o.extend(e[a],i,s[a])):e[a]=s[a]}return e},o.clone=function(e,t){return o.extend({},t,e)},o.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},o.values=function(e){var t=[];if(Object.keys){
|
|
||||||
for(var n=Object.keys(e),o=0;o<n.length;o++)t.push(e[n[o]]);return t}for(var i in e)t.push(e[i]);return t},o.get=function(e,t,n,o){t=t.split(".").slice(n,o);for(var i=0;i<t.length;i+=1)e=e[t[i]];return e},o.set=function(e,t,n,i,r){var s=t.split(".").slice(i,r);return o.get(e,t,0,-1)[s[s.length-1]]=n,n},o.shuffle=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(o.random()*(t+1)),i=e[t];e[t]=e[n],e[n]=i}return e},o.choose=function(e){return e[Math.floor(o.random()*e.length)]},o.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},o.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isFunction=function(e){return"function"==typeof e},o.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},o.isString=function(e){return"[object String]"===toString.call(e)},o.clamp=function(e,t,n){return e<t?t:e>n?n:e},o.sign=function(e){return e<0?-1:1},o.now=function(){
|
|
||||||
if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-o._nowStartTime},o.random=function(e,n){return e=void 0!==e?e:0,n=void 0!==n?n:1,e+t()*(n-e)};var t=function(){return o._seed=(9301*o._seed+49297)%233280,o._seed/233280};o.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},o.logLevel=1,o.log=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.info=function(){console&&o.logLevel>0&&o.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.warn=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.nextId=function(){return o._nextId++},
|
|
||||||
o.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},o.map=function(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o<e.length;o+=1)n.push(t(e[o]));return n},o.topologicalSort=function(e){var t=[],n=[],i=[];for(var r in e)n[r]||i[r]||o._topologicalSort(r,n,i,e,t);return t},o._topologicalSort=function(e,t,n,i,r){var s=i[e]||[];n[e]=!0;for(var a=0;a<s.length;a+=1){var l=s[a];n[l]||(t[l]||o._topologicalSort(l,t,n,i,r))}n[e]=!1,t[e]=!0,r.push(e)},o.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var o=function(){for(var t,n=new Array(arguments.length),o=0,i=arguments.length;o<i;o++)n[o]=arguments[o];for(o=0;o<e.length;o+=1){var r=e[o].apply(t,n);void 0!==r&&(t=r)}return t};return o._chained=e,o},o.chainPathBefore=function(e,t,n){return o.set(e,t,o.chain(n,o.get(e,t)))},o.chainPathAfter=function(e,t,n){return o.set(e,t,o.chain(o.get(e,t),n))},
|
|
||||||
o._requireGlobal=function(t,o){return("undefined"!=typeof window?window[t]:void 0!==n?n[t]:null)||e(o)}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(e,t,n){var o={};t.exports=o;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),m=e("../body/Body");!function(){o.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null,t=t||{},(e||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},o=f.extend(n,t);if(e||o.render){var r={element:e,controller:a};o.render=f.extend(r,o.render)}
|
|
||||||
return o.render&&o.render.controller&&(o.render=o.render.controller.create(o.render)),o.render&&(o.render.engine=o),o.world=t.world||i.create(o.world),o.pairs=l.create(),o.broadphase=o.broadphase.controller.create(o.broadphase),o.metrics=o.metrics||{extended:!1},o},o.update=function(e,t,n){t=t||1e3/60,n=n||1;var i,a=e.world,c=e.timing,f=e.broadphase,m=[];c.timestamp+=t*c.timeScale;var v={timestamp:c.timestamp};d.trigger(e,"beforeUpdate",v);var y=u.allBodies(a),g=u.allConstraints(a);for(e.enableSleeping&&r.update(y,c.timeScale),o._bodiesApplyGravity(y,a.gravity),o._bodiesUpdate(y,t,c.timeScale,n,a.bounds),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);p.postSolveAll(y),f.controller?(a.isModified&&f.controller.clear(f),f.controller.update(f,y,e,a.isModified),m=f.pairsList):m=y,a.isModified&&u.setModified(a,!1,!1,!0);var x=f.detector(m,e),h=e.pairs,b=c.timestamp;for(l.update(h,x,b),l.removeOld(h,b),e.enableSleeping&&r.afterCollisions(h.list,c.timeScale),
|
|
||||||
h.collisionStart.length>0&&d.trigger(e,"collisionStart",{pairs:h.collisionStart}),s.preSolvePosition(h.list),i=0;i<e.positionIterations;i++)s.solvePosition(h.list,c.timeScale);for(s.postSolvePosition(y),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);for(p.postSolveAll(y),s.preSolveVelocity(h.list),i=0;i<e.velocityIterations;i++)s.solveVelocity(h.list,c.timeScale);return h.collisionActive.length>0&&d.trigger(e,"collisionActive",{pairs:h.collisionActive}),h.collisionEnd.length>0&&d.trigger(e,"collisionEnd",{pairs:h.collisionEnd}),o._bodiesClearForces(y),d.trigger(e,"afterUpdate",v),e},o.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,o.clear(e);for(var n=u.allBodies(e.world),i=0;i<n.length;i++){var s=n[i];r.set(s,!1),s.id=f.nextId()}}},o.clear=function(e){var t=e.world;l.clear(e.pairs);var n=e.broadphase;if(n.controller){var o=u.allBodies(t);n.controller.clear(n),n.controller.update(n,o,e,!0)}},o._bodiesClearForces=function(e){
|
|
||||||
for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},o._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<e.length;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},o._bodiesUpdate=function(e,t,n,o,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||m.update(s,t,n,o)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":31,"./Common":14,"./Events":16,"./Metrics":18,"./Sleeping":22}],16:[function(e,t,n){var o={};t.exports=o;var i=e("./Common");!function(){o.on=function(e,t,n){for(var o,i=t.split(" "),r=0;r<i.length;r++)o=i[r],e.events=e.events||{},e.events[o]=e.events[o]||[],e.events[o].push(n);return n},o.off=function(e,t,n){if(!t)return void(e.events={});"function"==typeof t&&(n=t,t=i.keys(e.events).join(" "))
|
|
||||||
;for(var o=t.split(" "),r=0;r<o.length;r++){var s=e.events[o[r]],a=[];if(n&&s)for(var l=0;l<s.length;l++)s[l]!==n&&a.push(s[l]);e.events[o[r]]=a}},o.trigger=function(e,t,n){var o,r,s,a;if(e.events){n||(n={}),o=t.split(" ");for(var l=0;l<o.length;l++)if(r=o[l],s=e.events[r]){a=i.clone(n,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,n){var o={};t.exports=o;var i=e("./Plugin"),r=e("./Common");!function(){o.name="matter-js",o.version="0.14.2",o.uses=[],o.used=[],o.use=function(){i.use(o,Array.prototype.slice.call(arguments))},o.before=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathBefore(o,e,t)},o.after=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathAfter(o,e,t)}}()},{"./Common":14,"./Plugin":20}],18:[function(e,t,n){},{"../body/Composite":2,"./Common":14}],19:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Common");!function(){o.create=function(e){var t={}
|
|
||||||
;return e||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=t.element.getAttribute("data-pixel-ratio")||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,
|
|
||||||
t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},o.setElement(t,t.element),t},o.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},
|
|
||||||
o.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},o.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o._getRelativeMousePosition=function(e,t,n){var o,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(o=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(o=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:o/(t.clientWidth/(t.width||t.clientWidth)*n),y:i/(t.clientHeight/(t.height||t.clientHeight)*n)}}}()},{"../core/Common":14}],20:[function(e,t,n){
|
|
||||||
var o={};t.exports=o;var i=e("./Common");!function(){o._registry={},o.register=function(e){if(o.isPlugin(e)||i.warn("Plugin.register:",o.toString(e),"does not implement all required fields."),e.name in o._registry){var t=o._registry[e.name],n=o.versionParse(e.version).number,r=o.versionParse(t.version).number;n>r?(i.warn("Plugin.register:",o.toString(t),"was upgraded to",o.toString(e)),o._registry[e.name]=e):n<r?i.warn("Plugin.register:",o.toString(t),"can not be downgraded to",o.toString(e)):e!==t&&i.warn("Plugin.register:",o.toString(e),"is already registered to different plugin object")}else o._registry[e.name]=e;return e},o.resolve=function(e){return o._registry[o.dependencyParse(e).name]},o.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},o.isPlugin=function(e){return e&&e.name&&e.version&&e.install},o.isUsed=function(e,t){return e.used.indexOf(t)>-1},o.isFor=function(e,t){var n=e.for&&o.dependencyParse(e.for)
|
|
||||||
;return!e.for||t.name===n.name&&o.versionSatisfies(t.version,n.range)},o.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0===e.uses.length)return void i.warn("Plugin.use:",o.toString(e),"does not specify any dependencies to install.");for(var n=o.dependencies(e),r=i.topologicalSort(n),s=[],a=0;a<r.length;a+=1)if(r[a]!==e.name){var l=o.resolve(r[a]);l?o.isUsed(e,l.name)||(o.isFor(l,e)||(i.warn("Plugin.use:",o.toString(l),"is for",l.for,"but installed on",o.toString(e)+"."),l._warned=!0),l.install?l.install(e):(i.warn("Plugin.use:",o.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(s.push("🔶 "+o.toString(l)),delete l._warned):s.push("✅ "+o.toString(l)),e.used.push(l.name)):s.push("❌ "+r[a])}s.length>0&&i.info(s.join(" "))},o.dependencies=function(e,t){var n=o.dependencyParse(e),r=n.name;if(t=t||{},!(r in t)){e=o.resolve(e)||e,t[r]=i.map(e.uses||[],function(t){o.isPlugin(t)&&o.register(t);var r=o.dependencyParse(t),s=o.resolve(t)
|
|
||||||
;return s&&!o.versionSatisfies(s.version,r.range)?(i.warn("Plugin.dependencies:",o.toString(s),"does not satisfy",o.toString(r),"used by",o.toString(n)+"."),s._warned=!0,e._warned=!0):s||(i.warn("Plugin.dependencies:",o.toString(t),"used by",o.toString(n),"could not be resolved."),e._warned=!0),r.name});for(var s=0;s<t[r].length;s+=1)o.dependencies(t[r][s],t);return t}},o.dependencyParse=function(e){if(i.isString(e)){return/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||i.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}}return{name:e.name,range:e.range||e.version}},o.versionParse=function(e){/^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(e)||i.warn("Plugin.versionParse:",e,"is not a valid version or range.");var t=e.split("-");e=t[0];var n=isNaN(Number(e[0])),o=n?e.substr(1):e,r=i.map(o.split("."),function(e){return Number(e)});return{isRange:n,version:o,range:e,operator:n?e[0]:"",parts:r,
|
|
||||||
prerelease:t[1],number:1e8*r[0]+1e4*r[1]+r[2]}},o.versionSatisfies=function(e,t){t=t||"*";var n=o.versionParse(t),i=n.parts,r=o.versionParse(e),s=r.parts;if(n.isRange){if("*"===n.operator||"*"===e)return!0;if("~"===n.operator)return s[0]===i[0]&&s[1]===i[1]&&s[2]>=i[2];if("^"===n.operator)return i[0]>0?s[0]===i[0]&&r.number>=n.number:i[1]>0?s[1]===i[1]&&s[2]>=i[2]:s[2]===i[2]}return e===t||"*"===e}}()},{"./Common":14}],21:[function(e,t,n){var o={};t.exports=o;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;if("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!e){var n;e=function(e){n=setTimeout(function(){e(s.now())},1e3/60)},t=function(){clearTimeout(n)}}o.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,
|
|
||||||
counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},n=s.extend(t,e);return n.delta=n.delta||1e3/n.fps,n.deltaMin=n.deltaMin||1e3/n.fps,n.deltaMax=n.deltaMax||1e3/(.5*n.fps),n.fps=1e3/n.delta,n},o.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=o.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&o.tick(t,n,r)}(),t},o.tick=function(e,t,n){var o,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?o=e.delta:(o=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(o),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),o=Math.min.apply(null,e.deltaHistory),o=o<e.deltaMin?e.deltaMin:o,o=o>e.deltaMax?e.deltaMax:o,a=o/e.delta,e.delta=o),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,
|
|
||||||
n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,o,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t.render),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},o.stop=function(e){t(e.frameRequestId)},o.start=function(e,t){o.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],22:[function(e,t,n){var o={};t.exports=o;var i=e("./Events");!function(){o._motionWakeThreshold=.18,o._motionSleepThreshold=.08,o._minBias=.9,o.update=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed
|
|
||||||
;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=o._minBias*a+(1-o._minBias)*l,r.sleepThreshold>0&&r.motion<o._motionSleepThreshold*n?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&o.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else o.set(r,!1)}},o.afterCollisions=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>o._motionWakeThreshold*n&&o.set(c,!1)}}}},o.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}}()},{
|
|
||||||
"./Events":16}],23:[function(e,t,n){var o={};t.exports=o;var i,r=e("../geometry/Vertices"),s=e("../core/Common"),a=e("../body/Body"),l=e("../geometry/Bounds"),c=e("../geometry/Vector");!function(){o.rectangle=function(e,t,n,o,i){i=i||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:r.fromPath("L 0 0 L "+n+" 0 L "+n+" "+o+" L 0 "+o)};if(i.chamfer){var c=i.chamfer;l.vertices=r.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete i.chamfer}return a.create(s.extend({},l,i))},o.trapezoid=function(e,t,n,o,i,l){l=l||{},i*=.5;var c,d=(1-2*i)*n,u=n*i,p=u+d,f=p+u;c=i<.5?"L 0 0 L "+u+" "+-o+" L "+p+" "+-o+" L "+f+" 0":"L 0 0 L "+p+" "+-o+" L "+f+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:r.fromPath(c)};if(l.chamfer){var v=l.chamfer;m.vertices=r.chamfer(m.vertices,v.radius,v.quality,v.qualityMin,v.qualityMax),delete l.chamfer}return a.create(s.extend({},m,l))},o.circle=function(e,t,n,i,r){i=i||{};var a={label:"Circle Body",circleRadius:n};r=r||25
|
|
||||||
;var l=Math.ceil(Math.max(10,Math.min(r,n)));return l%2==1&&(l+=1),o.polygon(e,t,l,n,s.extend({},a,i))},o.polygon=function(e,t,n,i,l){if(l=l||{},n<3)return o.circle(e,t,i,l);for(var c=2*Math.PI/n,d="",u=.5*c,p=0;p<n;p+=1){var f=u+p*c,m=Math.cos(f)*i,v=Math.sin(f)*i;d+="L "+m.toFixed(3)+" "+v.toFixed(3)+" "}var y={label:"Polygon Body",position:{x:e,y:t},vertices:r.fromPath(d)};if(l.chamfer){var g=l.chamfer;y.vertices=r.chamfer(y.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return a.create(s.extend({},y,l))},o.fromVertices=function(e,t,n,o,d,u,p){i||(i=s._requireGlobal("decomp","poly-decomp"));var f,m,v,y,g,x,h,b,w;for(o=o||{},m=[],d=void 0!==d&&d,u=void 0!==u?u:.01,p=void 0!==p?p:10,i||s.warn("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull."),s.isArray(n[0])||(n=[n]),b=0;b<n.length;b+=1)if(y=n[b],(v=r.isConvex(y))||!i)y=v?r.clockwiseSort(y):r.hull(y),m.push({position:{x:e,y:t},vertices:y});else{
|
|
||||||
var S=y.map(function(e){return[e.x,e.y]});i.makeCCW(S),!1!==u&&i.removeCollinearPoints(S,u);var C=i.quickDecomp(S);for(g=0;g<C.length;g++){var A=C[g],P=A.map(function(e){return{x:e[0],y:e[1]}});p>0&&r.area(P)<p||m.push({position:r.centre(P),vertices:P})}}for(g=0;g<m.length;g++)m[g]=a.create(s.extend(m[g],o));if(d){for(g=0;g<m.length;g++){var B=m[g];for(x=g+1;x<m.length;x++){var M=m[x];if(l.overlaps(B.bounds,M.bounds)){var k=B.vertices,I=M.vertices;for(h=0;h<B.vertices.length;h++)for(w=0;w<M.vertices.length;w++){var _=c.magnitudeSquared(c.sub(k[(h+1)%k.length],I[w])),T=c.magnitudeSquared(c.sub(k[h],I[(w+1)%I.length]));_<5&&T<5&&(k[h].isInternal=!0,I[w].isInternal=!0)}}}}}return m.length>1?(f=a.create(s.extend({parts:m.slice(0)},o)),a.setPosition(f,{x:e,y:t}),f):m[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],24:[function(e,t,n){var o={};t.exports=o
|
|
||||||
;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){o.stack=function(e,t,n,o,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,m=0;m<o;m++){for(var v=0,y=0;y<n;y++){var g=l(u,p,y,m,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>v&&(v=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=v+s,u=e}return d},o.chain=function(e,t,n,o,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,m=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,y=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:m*t,y:f*n},bodyB:p,pointB:{x:y*o,y:v*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},o.mesh=function(e,t,n,o,a){var l,c,d,u,p,f=e.bodies;for(l=0;l<n;l++){for(c=1;c<t;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)))
|
|
||||||
;if(l>0)for(c=0;c<t;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),o&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),o&&c<t-1&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},o.pyramid=function(e,t,n,i,r,s,l){return o.stack(e,t,n,i,r,s,function(t,o,s,c,d,u){var p=Math.min(i,Math.ceil(n/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var m=c,v=n-1-c;if(!(s<m||s>v)){1===u&&a.translate(d,{x:(s+(n%2==1?1:-1))*f,y:0});return l(e+(d?s*f:0)+s*r,o,s,c,d,u)}}})},o.newtonsCradle=function(e,t,n,o,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;c<n;c++){var d=l.circle(e+c*(1.9*o),t+s,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=r.create({pointA:{x:e+c*(1.9*o),y:t},bodyB:d});i.addBody(a,d),i.addConstraint(a,u)}return a},o.car=function(e,t,n,o,s){var c=a.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=i.create({label:"Car"
|
|
||||||
}),f=l.rectangle(e,t,n,o,{collisionFilter:{group:c},chamfer:{radius:.5*o},density:2e-4}),m=l.circle(e+d,t+0,s,{collisionFilter:{group:c},friction:.8}),v=l.circle(e+u,t+0,s,{collisionFilter:{group:c},friction:.8}),y=r.create({bodyB:f,pointB:{x:d,y:0},bodyA:m,stiffness:1,length:0}),g=r.create({bodyB:f,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return i.addBody(p,f),i.addBody(p,m),i.addBody(p,v),i.addConstraint(p,y),i.addConstraint(p,g),p},o.softBody=function(e,t,n,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var f=o.stack(e,t,n,i,r,a,function(e,t){return l.circle(e,t,d,u)});return o.mesh(f,n,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":23}],25:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){
|
|
||||||
var o=(n+1)%e.length,s=i.normalise({x:e[o].y-e[n].y,y:e[n].x-e[o].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},o.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*n-s.y*o,s.y=s.x*o+s.y*n,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":28}],26:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&o.update(t,e),t},o.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var o=0;o<t.length;o++){var i=t[o];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},o.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},o.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},o.translate=function(e,t){e.min.x+=t.x,
|
|
||||||
e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},o.shift=function(e,t){var n=e.max.x-e.min.x,o=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+o}}()},{}],27:[function(e,t,n){var o={};t.exports=o;var i=(e("../geometry/Bounds"),e("../core/Common"));!function(){o.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,r,s,a,l,c,d,u,p,f,m,v,y=[],g=0,x=0,h=0;t=t||15;var b=function(e,t,n){var o=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&o?(m=p.x,v=p.y):(m=0,v=0);var i={x:m+e,y:v+t};!o&&p||(p=i),y.push(i),x=m+e,h=v+t}},w=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":x=e.x,h=e.y;break;case"H":x=e.x;break;case"V":h=e.y}b(x,h,e.pathSegType)}};for(o._svgPathToAbsolute(e),s=e.getTotalLength(),c=[],n=0;n<e.pathSegList.numberOfItems;n+=1)c.push(e.pathSegList.getItem(n));for(d=c.concat();g<s;){
|
|
||||||
if(f=e.getPathSegAtLength(g),(l=c[f])!=u){for(;d.length&&d[0]!=l;)w(d.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=e.getPointAtLength(g),b(a.x,a.y,0)}g+=t}for(n=0,r=d.length;n<r;++n)w(d[n]);return y},o._svgPathToAbsolute=function(e){for(var t,n,o,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;u<d;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(o=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,o,i,r,s),u);break;case"s":
|
|
||||||
a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,o,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=n}"M"!=f&&"m"!=f||(t=l,n=c)}}}()},{"../core/Common":14,"../geometry/Bounds":26}],28:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e,t){return{x:e||0,y:t||0}},o.clone=function(e){return{x:e.x,y:e.y}},o.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},o.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},o.rotate=function(e,t,n){var o=Math.cos(t),i=Math.sin(t);n||(n={});var r=e.x*o-e.y*i;return n.y=e.x*i+e.y*o,n.x=r,n},o.rotateAbout=function(e,t,n,o){var i=Math.cos(t),r=Math.sin(t);o||(o={});var s=n.x+((e.x-n.x)*i-(e.y-n.y)*r);return o.y=n.y+((e.x-n.x)*r+(e.y-n.y)*i),o.x=s,o},o.normalise=function(e){
|
|
||||||
var t=o.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},o.dot=function(e,t){return e.x*t.x+e.y*t.y},o.cross=function(e,t){return e.x*t.y-e.y*t.x},o.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},o.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},o.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},o.mult=function(e,t){return{x:e.x*t,y:e.y*t}},o.div=function(e,t){return{x:e.x/t,y:e.y/t}},o.perp=function(e,t){return t=!0===t?-1:1,{x:t*-e.y,y:t*e.x}},o.neg=function(e){return{x:-e.x,y:-e.y}},o.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},o._temp=[o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}()},{}],29:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.create=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o],r={x:i.x,y:i.y,index:o,body:t,isInternal:!1};n.push(r)}return n},o.fromPath=function(e,t){
|
|
||||||
var n=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(n,function(e,t,n){i.push({x:parseFloat(t),y:parseFloat(n)})}),o.create(i,t)},o.centre=function(e){for(var t,n,r,s=o.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),n=i.mult(i.add(e[l],e[r]),t),a=i.add(a,n);return i.div(a,6*s)},o.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return i.div(t,e.length)},o.area=function(e,t){for(var n=0,o=e.length-1,i=0;i<e.length;i++)n+=(e[o].x-e[i].x)*(e[o].y+e[i].y),o=i;return t?n/2:Math.abs(n)/2},o.inertia=function(e,t){for(var n,o,r=0,s=0,a=e,l=0;l<a.length;l++)o=(l+1)%a.length,n=Math.abs(i.cross(a[o],a[l])),r+=n*(i.dot(a[o],a[o])+i.dot(a[o],a[l])+i.dot(a[l],a[l])),s+=n;return t/6*(r/s)},o.translate=function(e,t,n){var o;if(n)for(o=0;o<e.length;o++)e[o].x+=t.x*n,e[o].y+=t.y*n;else for(o=0;o<e.length;o++)e[o].x+=t.x,e[o].y+=t.y;return e},o.rotate=function(e,t,n){if(0!==t){
|
|
||||||
for(var o=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-n.x,l=s.y-n.y;s.x=n.x+(a*o-l*i),s.y=n.y+(a*i+l*o)}return e}},o.contains=function(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=e[(n+1)%e.length];if((t.x-o.x)*(i.y-o.y)+(t.y-o.y)*(o.x-i.x)>0)return!1}return!0},o.scale=function(e,t,n,r){if(1===t&&1===n)return e;r=r||o.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*n;return e},o.chamfer=function(e,t,n,o,s){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,o=o||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),m=i.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),y=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,m),.5)),x=i.sub(d,i.mult(g,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,o,s),h%2==1&&(h+=1)
|
|
||||||
;for(var b=Math.acos(i.dot(f,m)),w=b/h,S=0;S<h;S++)a.push(i.add(i.rotate(y,w*S),x))}else a.push(d)}return a},o.clockwiseSort=function(e){var t=o.mean(e);return e.sort(function(e,n){return i.angle(t,e)-i.angle(t,n)}),e},o.isConvex=function(e){var t,n,o,i,r=0,s=e.length;if(s<3)return null;for(t=0;t<s;t++)if(n=(t+1)%s,o=(t+2)%s,i=(e[n].x-e[t].x)*(e[o].y-e[n].y),i-=(e[n].y-e[t].y)*(e[o].x-e[n].x),i<0?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r||null},o.hull=function(e){var t,n,o=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y}),n=0;n<e.length;n+=1){for(t=e[n];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];o.length>=2&&i.cross3(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return o.pop(),r.pop(),o.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":28}],30:[function(e,t,n){var o=t.exports=e("../core/Matter");o.Body=e("../body/Body"),o.Composite=e("../body/Composite"),
|
|
||||||
o.World=e("../body/World"),o.Contact=e("../collision/Contact"),o.Detector=e("../collision/Detector"),o.Grid=e("../collision/Grid"),o.Pairs=e("../collision/Pairs"),o.Pair=e("../collision/Pair"),o.Query=e("../collision/Query"),o.Resolver=e("../collision/Resolver"),o.SAT=e("../collision/SAT"),o.Constraint=e("../constraint/Constraint"),o.MouseConstraint=e("../constraint/MouseConstraint"),o.Common=e("../core/Common"),o.Engine=e("../core/Engine"),o.Events=e("../core/Events"),o.Mouse=e("../core/Mouse"),o.Runner=e("../core/Runner"),o.Sleeping=e("../core/Sleeping"),o.Plugin=e("../core/Plugin"),o.Bodies=e("../factory/Bodies"),o.Composites=e("../factory/Composites"),o.Axes=e("../geometry/Axes"),o.Bounds=e("../geometry/Bounds"),o.Svg=e("../geometry/Svg"),o.Vector=e("../geometry/Vector"),o.Vertices=e("../geometry/Vertices"),o.Render=e("../render/Render"),o.RenderPixi=e("../render/RenderPixi"),o.World.add=o.Composite.add,o.World.remove=o.Composite.remove,
|
|
||||||
o.World.addComposite=o.Composite.addComposite,o.World.addBody=o.Composite.addBody,o.World.addConstraint=o.Composite.addConstraint,o.World.clear=o.Composite.clear,o.Engine.run=o.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Matter":17,"../core/Metrics":18,"../core/Mouse":19,"../core/Plugin":20,"../core/Runner":21,"../core/Sleeping":22,"../factory/Bodies":23,"../factory/Composites":24,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Svg":27,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31,"../render/RenderPixi":32}],31:[function(e,t,n){var o={};t.exports=o
|
|
||||||
;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector"),d=e("../core/Mouse");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(i.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){var t={controller:o,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#18181d",wireframeBackground:"#0f0f13",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,
|
|
||||||
showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(t,e);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=e.mouse,r.engine=e.engine,r.canvas=r.canvas||n(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&o.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):r.canvas.parentNode||i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.setPixelRatio=function(e,t){var n=e.options,o=e.canvas;"auto"===t&&(t=u(o)),n.pixelRatio=t,o.setAttribute("data-pixel-ratio",t),o.width=n.width*t,o.height=n.height*t,o.style.width=n.width+"px",
|
|
||||||
o.style.height=n.height+"px",e.context.scale(t,t)},o.lookAt=function(e,t,n,o){o=void 0===o||o,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var r={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},s=0;s<t.length;s+=1){var a=t[s],l=a.bounds?a.bounds.min:a.min||a.position||a,c=a.bounds?a.bounds.max:a.max||a.position||a;l&&c&&(l.x<r.min.x&&(r.min.x=l.x),c.x>r.max.x&&(r.max.x=c.x),l.y<r.min.y&&(r.min.y=l.y),c.y>r.max.y&&(r.max.y=c.y))}var u=r.max.x-r.min.x+2*n.x,p=r.max.y-r.min.y+2*n.y,f=e.canvas.height,m=e.canvas.width,v=m/f,y=u/p,g=1,x=1;y>v?x=y/v:g=v/y,e.options.hasBounds=!0,e.bounds.min.x=r.min.x,e.bounds.max.x=r.min.x+u*g,e.bounds.min.y=r.min.y,e.bounds.max.y=r.min.y+p*x,o&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*x*.5,e.bounds.max.y+=.5*p-p*x*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),
|
|
||||||
d.setOffset(e.mouse,e.bounds.min))},o.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,o=t/e.options.width,i=n/e.options.height;e.context.scale(1/o,1/i),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},o.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},o.world=function(e){var t,n=e.engine,i=n.world,u=e.canvas,p=e.context,m=e.options,v=r.allBodies(i),y=r.allConstraints(i),g=m.wireframes?m.wireframeBackground:m.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(a.trigger(e,"beforeRender",b),e.currentBackground!==g&&f(e,g),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",m.hasBounds){for(t=0;t<v.length;t++){var w=v[t];s.overlaps(w.bounds,e.bounds)&&x.push(w)}for(t=0;t<y.length;t++){var S=y[t],C=S.bodyA,A=S.bodyB,P=S.pointA,B=S.pointB;C&&(P=c.add(C.position,S.pointA)),
|
|
||||||
A&&(B=c.add(A.position,S.pointB)),P&&B&&((s.contains(e.bounds,P)||s.contains(e.bounds,B))&&h.push(S))}o.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))}else h=y,x=v;!m.wireframes||n.enableSleeping&&m.showSleeping?o.bodies(e,x,p):(m.showConvexHulls&&o.bodyConvexHulls(e,x,p),o.bodyWireframes(e,x,p)),m.showBounds&&o.bodyBounds(e,x,p),(m.showAxes||m.showAngleIndicator)&&o.bodyAxes(e,x,p),m.showPositions&&o.bodyPositions(e,x,p),m.showVelocity&&o.bodyVelocity(e,x,p),m.showIds&&o.bodyIds(e,x,p),m.showSeparations&&o.separations(e,n.pairs.list,p),m.showCollisions&&o.collisions(e,n.pairs.list,p),m.showVertexNumbers&&o.vertexNumbers(e,x,p),m.showMousePosition&&o.mousePosition(e,e.mouse,p),o.constraints(h,p),m.showBroadphase&&n.broadphase.controller===l&&o.grid(e,n.broadphase,p),m.showDebug&&o.debug(e,p),m.hasBounds&&o.endViewTransform(e),
|
|
||||||
a.trigger(e,"afterRender",b)},o.debug=function(e,t){var n=t,o=e.engine,i=o.world,s=o.metrics,a=e.options;r.allBodies(i);if(o.timing.timestamp-(e.debugTimestamp||0)>=500){var l="";s.timing&&(l+="fps: "+Math.round(s.timing.fps)+" "),e.debugString=l,e.debugTimestamp=o.timing.timestamp}if(e.debugString){n.font="12px Arial",a.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var c=e.debugString.split("\n"),d=0;d<c.length;d++)n.fillText(c[d],50,50+18*d)}},o.constraints=function(e,t){for(var n=t,o=0;o<e.length;o++){var r=e[o];if(r.render.visible&&r.pointA&&r.pointB){var s,a,l=r.bodyA,d=r.bodyB;if(s=l?c.add(l.position,r.pointA):r.pointA,"pin"===r.render.type)n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath();else{if(a=d?c.add(d.position,r.pointB):r.pointB,n.beginPath(),n.moveTo(s.x,s.y),"spring"===r.render.type)for(var u,p=c.sub(a,s),f=c.perp(c.normalise(p)),m=Math.ceil(i.clamp(r.length/5,12,20)),v=1;v<m;v+=1)u=v%2==0?1:-1,
|
|
||||||
n.lineTo(s.x+p.x*(v/m)+f.x*u*4,s.y+p.y*(v/m)+f.y*u*4);n.lineTo(a.x,a.y)}r.render.lineWidth&&(n.lineWidth=r.render.lineWidth,n.strokeStyle=r.render.strokeStyle,n.stroke()),r.render.anchors&&(n.fillStyle=r.render.strokeStyle,n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},o.bodyShadows=function(e,t,n){for(var o=n,i=(e.engine,0);i<t.length;i++){var r=t[i];if(r.render.visible){if(r.circleRadius)o.beginPath(),o.arc(r.position.x,r.position.y,r.circleRadius,0,2*Math.PI),o.closePath();else{o.beginPath(),o.moveTo(r.vertices[0].x,r.vertices[0].y);for(var s=1;s<r.vertices.length;s++)o.lineTo(r.vertices[s].x,r.vertices[s].y);o.closePath()}var a=r.position.x-.5*e.options.width,l=r.position.y-.2*e.options.height,c=Math.abs(a)+Math.abs(l);o.shadowColor="rgba(0,0,0,0.15)",o.shadowOffsetX=.05*a,o.shadowOffsetY=.05*l,o.shadowBlur=1+12*Math.min(1,c/1e3),o.fill(),o.shadowColor=null,o.shadowOffsetX=null,o.shadowOffsetY=null,o.shadowBlur=null}}},
|
|
||||||
o.bodies=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options),c=l.showInternalEdges||!l.wireframes;for(r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=o.parts.length>1?1:0;s<o.parts.length;s++)if(i=o.parts[s],i.render.visible){if(l.showSleeping&&o.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var d=i.render.sprite,u=p(e,d.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var f=1;f<i.vertices.length;f++)!i.vertices[f-1].isInternal||c?a.lineTo(i.vertices[f].x,i.vertices[f].y):a.moveTo(i.vertices[f].x,i.vertices[f].y),
|
|
||||||
i.vertices[f].isInternal&&!c&&a.moveTo(i.vertices[(f+1)%i.vertices.length].x,i.vertices[(f+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle="#bbb",a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},o.bodyWireframes=function(e,t,n){var o,i,r,s,a,l=n,c=e.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(a=o.parts.length>1?1:0;a<o.parts.length;a++){for(i=o.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},
|
|
||||||
o.bodyConvexHulls=function(e,t,n){var o,i,r,s=n;for(s.beginPath(),i=0;i<t.length;i++)if(o=t[i],o.render.visible&&1!==o.parts.length){for(s.moveTo(o.vertices[0].x,o.vertices[0].y),r=1;r<o.vertices.length;r++)s.lineTo(o.vertices[r].x,o.vertices[r].y);s.lineTo(o.vertices[0].x,o.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},o.vertexNumbers=function(e,t,n){var o,i,r,s=n;for(o=0;o<t.length;o++){var a=t[o].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(o+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},o.mousePosition=function(e,t,n){var o=n;o.fillStyle="rgba(255,255,255,0.8)",o.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},o.bodyBounds=function(e,t,n){var o=n,i=(e.engine,e.options);o.beginPath();for(var r=0;r<t.length;r++){
|
|
||||||
if(t[r].render.visible)for(var s=t[r].parts,a=s.length>1?1:0;a<s.length;a++){var l=s[a];o.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}}i.wireframes?o.strokeStyle="rgba(255,255,255,0.08)":o.strokeStyle="rgba(0,0,0,0.1)",o.lineWidth=1,o.stroke()},o.bodyAxes=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),i=0;i<t.length;i++){var c=t[i],d=c.parts;if(c.render.visible)if(l.showAxes)for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++){var u=o.axes[s];a.moveTo(o.position.x,o.position.y),a.lineTo(o.position.x+20*u.x,o.position.y+20*u.y)}else for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++)a.moveTo(o.position.x,o.position.y),a.lineTo((o.vertices[0].x+o.vertices[o.vertices.length-1].x)/2,(o.vertices[0].y+o.vertices[o.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",
|
|
||||||
a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},o.bodyPositions=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=0;s<o.parts.length;s++)i=o.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)o=t[r],o.render.visible&&(a.arc(o.positionPrev.x,o.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},o.bodyVelocity=function(e,t,n){var o=n;o.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(o.moveTo(r.position.x,r.position.y),o.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}o.lineWidth=3,o.strokeStyle="cornflowerblue",o.stroke()},o.bodyIds=function(e,t,n){var o,i,r=n;for(o=0;o<t.length;o++)if(t[o].render.visible){var s=t[o].parts
|
|
||||||
;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},o.collisions=function(e,t,n){var o,i,r,s,a=n,l=e.options;for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive)for(i=o.collision,s=0;s<o.activeContacts.length;s++){var c=o.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive&&(i=o.collision,o.activeContacts.length>0)){var u=o.activeContacts[0].vertex.x,p=o.activeContacts[0].vertex.y;2===o.activeContacts.length&&(u=(o.activeContacts[0].vertex.x+o.activeContacts[1].vertex.x)/2,p=(o.activeContacts[0].vertex.y+o.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}
|
|
||||||
l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},o.separations=function(e,t,n){var o,i,r,s,a,l=n,c=e.options;for(l.beginPath(),a=0;a<t.length;a++)if(o=t[a],o.isActive){i=o.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},o.grid=function(e,t,n){var o=n;e.options.wireframes?o.strokeStyle="rgba(255,180,0,0.1)":o.strokeStyle="rgba(255,180,0,0.5)",o.beginPath();for(var r=i.keys(t.buckets),s=0;s<r.length;s++){var a=r[s];if(!(t.buckets[a].length<2)){var l=a.split(/C|R/)
|
|
||||||
;o.rect(.5+parseInt(l[1],10)*t.bucketWidth,.5+parseInt(l[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}o.lineWidth=1,o.stroke()},o.inspector=function(e,t){var n,o=(e.engine,e.selected),i=e.render,r=i.options;if(r.hasBounds){var s=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=s/i.options.width,c=a/i.options.height;t.scale(1/l,1/c),t.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var d=0;d<o.length;d++){var u=o[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",
|
|
||||||
t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),r.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=new Image,n.src=t,n)},f=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,
|
|
||||||
"../core/Mouse":19,"../geometry/Bounds":26,"../geometry/Vector":28}],32:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Bounds"),r=e("../body/Composite"),s=e("../core/Common"),a=e("../core/Events"),l=e("../geometry/Vector");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){s.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:o,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,
|
|
||||||
showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=s.extend(t,e),i=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:i,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},a.on(n.engine,"beforeUpdate",function(){o.clear(n)}),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),s.isElement(n.element)?n.element.appendChild(n.canvas):s.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},
|
|
||||||
n.canvas.onselectstart=function(){return!1},n},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var o=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=o,o&&t.addChildAt(o,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},o.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),o=e.sprites["bg-0"];if(n){var i=s.colorToNumber(t);e.renderer.backgroundColor=i,o&&e.container.removeChild(o)}else if(!o){var r=d(e,t);o=e.sprites["bg-0"]=new PIXI.Sprite(r),o.position.x=0,o.position.y=0,e.container.addChildAt(o,0)}e.currentBackground=t}},o.world=function(e){
|
|
||||||
var t,n=e.engine,s=n.world,a=e.renderer,c=e.container,d=e.options,u=r.allBodies(s),p=r.allConstraints(s),f=[];d.wireframes?o.setBackground(e,d.wireframeBackground):o.setBackground(e,d.background);var m=e.bounds.max.x-e.bounds.min.x,v=e.bounds.max.y-e.bounds.min.y,y=m/e.options.width,g=v/e.options.height;if(d.hasBounds){for(t=0;t<u.length;t++){var x=u[t];x.render.sprite.visible=i.overlaps(x.bounds,e.bounds)}for(t=0;t<p.length;t++){var h=p[t],b=h.bodyA,w=h.bodyB,S=h.pointA,C=h.pointB;b&&(S=l.add(b.position,h.pointA)),w&&(C=l.add(w.position,h.pointB)),S&&C&&((i.contains(e.bounds,S)||i.contains(e.bounds,C))&&f.push(h))}c.scale.set(1/y,1/g),c.position.set(-e.bounds.min.x*(1/y),-e.bounds.min.y*(1/g))}else f=p;for(t=0;t<u.length;t++)o.body(e,u[t]);for(t=0;t<f.length;t++)o.constraint(e,f[t]);a.render(c)},o.constraint=function(e,t){var n=(e.engine,t.bodyA),o=t.bodyB,i=t.pointA,r=t.pointB,a=e.container,l=t.render,c="c-"+t.id,d=e.primitives[c];if(d||(d=e.primitives[c]=new PIXI.Graphics),
|
|
||||||
!l.visible||!t.pointA||!t.pointB)return void d.clear();-1===s.indexOf(a.children,d)&&a.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(l.lineWidth,s.colorToNumber(l.strokeStyle),1),n?d.moveTo(n.position.x+i.x,n.position.y+i.y):d.moveTo(i.x,i.y),o?d.lineTo(o.position.x+r.x,o.position.y+r.y):d.lineTo(r.x,r.y),d.endFill()},o.body=function(e,t){var o=(e.engine,t.render);if(o.visible)if(o.sprite&&o.sprite.texture){var i="b-"+t.id,r=e.sprites[i],a=e.spriteContainer;r||(r=e.sprites[i]=n(e,t)),-1===s.indexOf(a.children,r)&&a.addChild(r),r.position.x=t.position.x,r.position.y=t.position.y,r.rotation=t.angle,r.scale.x=o.sprite.xScale||1,r.scale.y=o.sprite.yScale||1}else{var l="b-"+t.id,d=e.primitives[l],u=e.container;d||(d=e.primitives[l]=c(e,t),d.initialAngle=t.angle),-1===s.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render,o=n.sprite.texture,i=d(e,o),r=new PIXI.Sprite(i)
|
|
||||||
;return r.anchor.x=t.render.sprite.xOffset,r.anchor.y=t.render.sprite.yOffset,r},c=function(e,t){var n,o=t.render,i=e.options,r=new PIXI.Graphics,a=s.colorToNumber(o.fillStyle),l=s.colorToNumber(o.strokeStyle),c=s.colorToNumber(o.strokeStyle),d=s.colorToNumber("#bbb"),u=s.colorToNumber("#CD5C5C");r.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],i.wireframes?(r.beginFill(0,0),r.lineStyle(1,d,1)):(r.beginFill(a,1),r.lineStyle(o.lineWidth,l,1)),r.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var f=1;f<n.vertices.length;f++)r.lineTo(n.vertices[f].x-t.position.x,n.vertices[f].y-t.position.y);r.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),r.endFill(),(i.showAngleIndicator||i.showAxes)&&(r.beginFill(0,0),i.wireframes?r.lineStyle(1,u,1):r.lineStyle(1,c),r.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),
|
|
||||||
r.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),r.endFill())}return r},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},{"../body/Composite":2,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"../geometry/Vector":28}]},{},[30])(30)});
|
|
||||||
17
style.css
17
style.css
@@ -128,10 +128,12 @@ summary {
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: none;
|
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
opacity: 0.6;
|
/* opacity: 0.6; */
|
||||||
/* transition: opacity 1.5s; */
|
/* display: none; */
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.25s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
#construct {
|
#construct {
|
||||||
@@ -145,11 +147,8 @@ summary {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
/* user-select: text; */
|
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
/* overflow: scroll; */
|
|
||||||
/* border-radius: 0px; */
|
|
||||||
border: 1px #333 solid;
|
border: 1px #333 solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +163,15 @@ summary {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
z-index: 12;
|
z-index: 12;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
display: none;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||||
grid-auto-rows: minmax(auto, auto);
|
grid-auto-rows: minmax(auto, auto);
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
/* box-shadow: 0px 0px 40px 20px rgba(255, 255, 255, 0.25); */
|
/* box-shadow: 0px 0px 40px 20px rgba(255, 255, 255, 0.25); */
|
||||||
|
display: grid;
|
||||||
|
/* none; */
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.25s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.choose-grid-module {
|
.choose-grid-module {
|
||||||
|
|||||||
59
todo.txt
59
todo.txt
@@ -1,13 +1,50 @@
|
|||||||
******************************************************** NEXT PATCH ********************************************************
|
******************************************************** NEXT PATCH ********************************************************
|
||||||
|
|
||||||
tech: pseudoscience - renewing power up choices costs no research, but adds 1-5 JUNK to the potential tech pool
|
to prevent misclicks when you grab two power ups in a row there is a 1/2 second delay before power up selections can register
|
||||||
|
I also added in a 0.25 fade in effect on the power up selection menu. Can you tell?
|
||||||
|
|
||||||
>update text now shows the last 20 updates and has a scroll bar
|
tech: pseudoscience - adds 0-4 JUNK to the potential tech pool (was 1-5 JUNK)
|
||||||
|
tech quenching - now increases max health and does harm for over healing from heal power ups
|
||||||
|
(was for heals at max health)
|
||||||
|
foam tech necrophoresis now makes less foam spawns if the total number of bullets is high
|
||||||
|
to help with lag when killing packs of mobs
|
||||||
|
|
||||||
|
preparation for more lore chapters
|
||||||
|
reworked the lore conversation code to make it easier to write
|
||||||
|
also lore conversations should now have better timing between the text and voice
|
||||||
|
lore conversations can now recover from some speech errors and try again with safer settings
|
||||||
|
this seems to allow speech on my firefox browser
|
||||||
|
added a console command to make it easier to quickly unlock testing mode
|
||||||
|
lore.unlockTesting()
|
||||||
|
|
||||||
|
pressing "b" in testing mode now gives you 10000 research and the damage from research tech
|
||||||
|
|
||||||
******************************************************** TODO ********************************************************
|
******************************************************** TODO ********************************************************
|
||||||
|
|
||||||
add a short pause before selection menu pops up
|
try crosshair invert colors
|
||||||
this stops a second selection popping up and a possible wrong selection
|
|
||||||
|
tech wave gun - no bullets just draw circle arcs that do damage to mobs near the circle arc
|
||||||
|
|
||||||
|
tech: quantized shields - harmonic standing wave field can only lose 33 energy per hit
|
||||||
|
draw 1,2,3 levels of the field based on energy?
|
||||||
|
the blocked value only scales up to 2x or 4x (33 energy) blocked
|
||||||
|
doesn't stack with spherical tech
|
||||||
|
|
||||||
|
tech: weak anthropic principle - instead of dieing drain 100 energy
|
||||||
|
too similar to MEE?
|
||||||
|
drain all your energy? or just 100
|
||||||
|
possible overpowered synergies
|
||||||
|
piezoelectricity, have to not activate
|
||||||
|
|
||||||
|
use SpeechSynthesis.speaking = T/F to generate the correct wait time on lore speech API and in game console text
|
||||||
|
https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API
|
||||||
|
|
||||||
|
or use the event listener to run even when speech ends
|
||||||
|
utterThis.addEventListener('end', function(event) {
|
||||||
|
console.log('Utterance has finished being spoken after ' + event.elapsedTime + ' milliseconds.');
|
||||||
|
});
|
||||||
|
|
||||||
|
in testing mode console log the body you click on
|
||||||
|
|
||||||
make a tech that improves all charge guns
|
make a tech that improves all charge guns
|
||||||
for: pulse, foam, rail gun
|
for: pulse, foam, rail gun
|
||||||
@@ -17,10 +54,6 @@ make a tech that improves all charge guns
|
|||||||
harm reduction while charging
|
harm reduction while charging
|
||||||
less ammo/energy used while charging?
|
less ammo/energy used while charging?
|
||||||
|
|
||||||
researching new tech doesn't cost any research, but adds 5-10 JUNK to the potential tech pool
|
|
||||||
|
|
||||||
in testing mode console log the body you click on
|
|
||||||
|
|
||||||
tech plasma : plasma length increases then decreases as you hold down the field button (like stabbing with a spear)
|
tech plasma : plasma length increases then decreases as you hold down the field button (like stabbing with a spear)
|
||||||
grows to 1.5 longer after 0.3 seconds, then returns to normal length over 1 second, until field is pressed again
|
grows to 1.5 longer after 0.3 seconds, then returns to normal length over 1 second, until field is pressed again
|
||||||
extra energy is drained when field is longer
|
extra energy is drained when field is longer
|
||||||
@@ -172,6 +205,12 @@ n-gon outreach ideas
|
|||||||
|
|
||||||
******************************************************** BUGS ********************************************************
|
******************************************************** BUGS ********************************************************
|
||||||
|
|
||||||
|
firefox ends if you try to use the voice API with an india voice
|
||||||
|
need to look at all voices and choose one that is available or go to default
|
||||||
|
|
||||||
|
death while in power up selection menu doesn't reset properly
|
||||||
|
of course it's not possible to die in this menu unless you use testing and shift+X
|
||||||
|
|
||||||
player can become crouched while not touching the ground if they exit the ground while crouched
|
player can become crouched while not touching the ground if they exit the ground while crouched
|
||||||
|
|
||||||
a couple times people have reported the final boss dropping extra bodies on death
|
a couple times people have reported the final boss dropping extra bodies on death
|
||||||
@@ -194,6 +233,8 @@ is there a way to check if the player is stuck inside the map or block
|
|||||||
|
|
||||||
******************************************************** LEVELS ********************************************************
|
******************************************************** LEVELS ********************************************************
|
||||||
|
|
||||||
|
try out making the player's "eye" a bigger circle
|
||||||
|
|
||||||
rename intro level to something lore related
|
rename intro level to something lore related
|
||||||
|
|
||||||
labs - procedural generation
|
labs - procedural generation
|
||||||
@@ -348,7 +389,7 @@ chapter 3: why is the bot attacking things?
|
|||||||
disable lore, but respawn on the level you die at?
|
disable lore, but respawn on the level you die at?
|
||||||
dialogue outline:
|
dialogue outline:
|
||||||
scientist try to think of a way to communicate since the bot can't talk
|
scientist try to think of a way to communicate since the bot can't talk
|
||||||
they give up on getting the bot to respond, and just start ask questions and thinking of explanations with other
|
they give up on getting the bot to respond, and just start ask questions and thinking of explanations with each other
|
||||||
when and how did it become self-aware
|
when and how did it become self-aware
|
||||||
why is the bot fighting things in these simulated locations?
|
why is the bot fighting things in these simulated locations?
|
||||||
it wasn't designed to be violent
|
it wasn't designed to be violent
|
||||||
|
|||||||
Reference in New Issue
Block a user