From 1a5366fa9c5fbabf7f07e111455e203ec25b0242 Mon Sep 17 00:00:00 2001 From: landgreen Date: Thu, 7 Nov 2019 06:05:42 -0800 Subject: [PATCH] textlog overlap --- js/bullets.js | 5 +++-- js/game.js | 11 ++++++++--- js/index.js | 2 ++ js/player.js | 5 +++++ js/powerups.js | 8 ++++++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index c382406..0d53915 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -162,6 +162,7 @@ const b = { } else { mech.fireCDcycle = mech.cycle + 30; //cooldown // game.makeTextLog("
NO AMMO
E / Q", 200); + game.replaceTextLog = true; game.makeTextLog("
NO AMMO

Q, E, and mouse wheel change weapons

", 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); } }, diff --git a/js/game.js b/js/game.js index 90a2ed7..26288ee 100644 --- a/js/game.js +++ b/js/game.js @@ -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("

PAUSED

", 1); // let text = "

PAUSED


" // //output current mod, field, and gun info when paused diff --git a/js/index.js b/js/index.js index e89b2aa..08e703c 100644 --- a/js/index.js +++ b/js/index.js @@ -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 diff --git a/js/player.js b/js/player.js index 426f467..a28cbfb 100644 --- a/js/player.js +++ b/js/player.js @@ -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(`
  ${mech.fieldUpgrades[mech.fieldMode].name}
(right click or space bar)

${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("
(right click or space bar)

", 1200); mech.setHoldDefaults(); mech.hold = function () { diff --git a/js/powerups.js b/js/powerups.js index 9a71a60..9a2e271 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -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(" heal " + (heal * 100).toFixed(0) + "%", 300) + if (heal > 0) game.makeTextLog(" heal " + (heal * 100).toFixed(0) + "%", 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("+" + ammo + " ammo for " + target.name + "", 300); + game.makeTextLog("+" + ammo + " ammo for " + target.name + "", 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(`
  ${b.mods[newMod].name}

${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("+" + ammo + " ammo for " + b.guns[ammoTarget].name + "", 300); } + game.replaceTextLog = false } }, spawnRandomPowerUp(x, y) { //mostly used after mob dies