textlog overlap

This commit is contained in:
landgreen
2019-11-07 06:05:42 -08:00
parent c835488f63
commit 1a5366fa9c
5 changed files with 24 additions and 7 deletions

View File

@@ -162,6 +162,7 @@ const b = {
} else {
mech.fireCDcycle = mech.cycle + 30; //cooldown
// game.makeTextLog("<div style='font-size:140%;'>NO AMMO</div><span class = 'box'>E</span> / <span class = 'box'>Q</span>", 200);
game.replaceTextLog = true;
game.makeTextLog("<div style='font-size:140%;'>NO AMMO</div> <p style='font-size:90%;'><strong>Q</strong>, <strong>E</strong>, and <strong>mouse wheel</strong> change weapons</p>", 200);
}
if (mech.isHolding) {
@@ -1163,7 +1164,7 @@ const b = {
have: false,
fire() {
const THRUST = 0.0015
const dir = mech.angle + (Math.random() - 0.5) * 0.7;
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
const me = bullet.length;
const RADIUS = (4 + 4 * Math.random()) * b.modBulletSize
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
@@ -1245,7 +1246,7 @@ const b = {
}
}
})
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 30 : 1, dir, me); //cd , speed
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices);
}
},

View File

@@ -172,14 +172,18 @@ const game = {
}
document.getElementById("mods").innerHTML = text
},
replaceTextLog: true,
makeTextLog(text, time = 180) {
document.getElementById("text-log").innerHTML = text;
document.getElementById("text-log").style.opacity = 1;
game.lastLogTime = mech.cycle + time;
if (game.replaceTextLog) {
document.getElementById("text-log").innerHTML = text;
document.getElementById("text-log").style.opacity = 1;
game.lastLogTime = mech.cycle + time;
}
},
textLog() {
if (game.lastLogTime && game.lastLogTime < mech.cycle) {
game.lastLogTime = 0;
game.replaceTextLog = true
// document.getElementById("text-log").innerHTML = " ";
document.getElementById("text-log").style.opacity = 0;
}
@@ -269,6 +273,7 @@ const game = {
requestAnimationFrame(cycle);
} else {
game.paused = true;
game.replaceTextLog = true;
game.makeTextLog("<h1>PAUSED</h1>", 1);
// let text = "<h1>PAUSED</h1><br><div style='font-size: 85%;'>"
// //output current mod, field, and gun info when paused

View File

@@ -34,10 +34,12 @@ field power up effects
field allows player to hold and throw living mobs
mod power ups ideas
double jump
bullet on mob damage effects
add to the array mob.do new mob behaviors
add a damage over time
add a freeze
give mobs more animal-like behaviors
like rainworld
give mobs something to do when they don't see player

View File

@@ -438,6 +438,7 @@ const mech = {
randomizeGuns()
randomizeField()
randomizeHealth()
game.replaceTextLog = true;
game.makeTextLog(`probability amplitude will synchronize in ${6-i} seconds`, 1000);
game.wipe = function () { //set wipe to have trails
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.003})`;
@@ -450,6 +451,7 @@ const mech = {
game.wipe = function () { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
game.replaceTextLog = true;
game.makeTextLog("your quantum probability has stabilized", 1000);
document.title = "n-gon: L" + (game.levelsCleared) + " " + level.levels[level.onLevel];
}, 8000);
@@ -947,7 +949,9 @@ const mech = {
},
hold() {},
fieldText() {
game.replaceTextLog = true;
game.makeTextLog(`<div class="circle field "></div> &nbsp; <strong style='font-size:30px;'>${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'>(right click or space bar)</span><br><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
game.replaceTextLog = false;
document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
},
fieldUpgrades: [{
@@ -956,6 +960,7 @@ const mech = {
effect: () => {
mech.fieldMode = 0;
mech.fieldText();
game.replaceTextLog = true; //allow text over write
// game.makeTextLog("<strong style='font-size:30px;'></strong><br> <span class='faded'>(right click or space bar)</span><p></p>", 1200);
mech.setHoldDefaults();
mech.hold = function () {

View File

@@ -11,7 +11,7 @@ const powerUps = {
let heal = (this.size / 40) ** 2
heal = Math.min(1 - mech.health, heal)
mech.addHealth(heal);
if (!game.lastLogTime && heal > 0) game.makeTextLog("<span style='font-size:115%;'> <strong class='color-h' style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
if (heal > 0) game.makeTextLog("<span style='font-size:115%;'> <strong class='color-h' style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
}
},
ammo: {
@@ -47,7 +47,7 @@ const powerUps = {
const ammo = Math.ceil((target.ammoPack * (0.5 + 0.08 * Math.random())) / b.dmgScale);
target.ammo += ammo;
game.updateGunHUD();
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
}
}
},
@@ -92,7 +92,9 @@ const powerUps = {
if (options.length > 0) {
let newMod = options[Math.floor(Math.random() * options.length)]
b.giveMod(newMod)
game.replaceTextLog = true;
game.makeTextLog(`<div class="circle mod"></div> &nbsp; <strong style='font-size:30px;'>${b.mods[newMod].name}</strong><br><br> ${b.mods[newMod].description}`, 1000);
game.replaceTextLog = false;
}
}
},
@@ -113,6 +115,7 @@ const powerUps = {
}
}
//give player a gun they don't already have if possible
game.replaceTextLog = true;
if (options.length > 0) {
let newGun = options[Math.floor(Math.random() * options.length)];
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
@@ -129,6 +132,7 @@ const powerUps = {
game.updateGunHUD();
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
}
game.replaceTextLog = false
}
},
spawnRandomPowerUp(x, y) { //mostly used after mob dies