diff options
Diffstat (limited to 'race')
-rw-r--r-- | race/cars/car1.js | 180 | ||||
-rw-r--r-- | race/pause.js | 2 |
2 files changed, 97 insertions, 85 deletions
diff --git a/race/cars/car1.js b/race/cars/car1.js index 0c4c9f0..448008c 100644 --- a/race/cars/car1.js +++ b/race/cars/car1.js @@ -8,11 +8,7 @@ startHooks.push(() => { car1startx = 388.9; car1starty = 79.4; } - if (online) { - car1collisionon = false; - } else { - car1collisionon = true; - } + car1collisionon = !online; car1enableOOBChecker = false; // Collision Manager @@ -20,7 +16,7 @@ startHooks.push(() => { if (!keysEnabled) { return; } if (started) { - carshb = document.getElementById("car0").getBoundingClientRect(); + carshb = document.getElementById("car1").getBoundingClientRect(); hitbox = document.getElementById("barrier").getBoundingClientRect(); var overlap = !(carshb.right < hitbox.left || @@ -28,12 +24,16 @@ startHooks.push(() => { carshb.bottom < hitbox.top || carshb.top > hitbox.bottom) - if (overlap) { - info("CarManager:car0", "Reversal prevented at X " + document.getElementById("car0").style.left + ", Y " + document.getElementById("car0").style.top); - document.getElementById("car0").style.left = car0startx + "px"; - document.getElementById("car0").style.top = car0starty + "px"; - document.getElementById("car0").style.transform = "rotate(0deg)"; - car0cspeed = 0; + if (overlap && car1collisionon) { + info("CarManager:car0", "Reversal prevented at X " + document.getElementById("car1").style.left + ", Y " + document.getElementById("car1").style.top); + car1collisionon = false; + document.getElementById("car1").style.left = car1startx + "px"; + document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; + car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } } @@ -55,14 +55,18 @@ startHooks.push(() => { if (location.search === "?sp") { scenar("wall2", "angry"); } - Sound.crash() + car1collisionon = false; + Sound.crash(); document.getElementById("car1").style.left = car1startx + "px"; document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; Array.from(document.getElementById('oil').children).forEach((item) => { spreadOil(item); }) - document.getElementById("car1").style.transform = "rotate(0deg)"; car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } }) @@ -76,79 +80,11 @@ startHooks.push(() => { carshb.top > hitbox.bottom) if (overlap) { - car1cspeed = 7; + car1cspeed = 5; } }) carshb = document.getElementById("car1").getBoundingClientRect(); - hitbox = document.getElementById("arrival").getBoundingClientRect(); - - var overlap = !(carshb.right < hitbox.left || - carshb.left > hitbox.right || - carshb.bottom < hitbox.top || - carshb.top > hitbox.bottom) - - if (overlap && started) { - started = false; - if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 4) { - info("CarManager:car1", "New lap"); - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 3) { - Sound.pass() - } else { - Sound.last() - } - document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); - if (location.search === "?sp") { - if ((document.getElementById('laps-car0').innerText.split("/")[0] - 1 + 1) > (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1)) { - scenar("ahead1", "angry"); - } else { - scenar("ahead2", "happy"); - } - } - } else { - info("CarManager:car1", "Car won the game"); - if (location.search === "?sp") { - scenar("won2", "happy"); - } - require('electron').ipcRenderer.send('addstats', { catalog: "results", key: "loses", add: 1 }); - try { document.getElementById('music').src = "about:blank"; } catch (e) { console.error(e); } - Sound.win(); - keysEnabled = false; - car1cspeed = 0; - car1speed = 0; - document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); - $("#box").fadeOut(500); - setTimeout(() => { - setTimeout(() => { - if (location.search === "?sp" || (online && role === "guest")) { - if (online) {} else { - location.href = "win.html?sp#car1"; - } - } else { - location.href = "win.html#car1"; - } - }, 3500) - }, 3000) - } - document.getElementById("car1").style.left = car1startx + "px"; - document.getElementById("car1").style.top = car1starty + "px"; - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - document.getElementById("car1").style.transform = "rotate(0deg)"; - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - car1cspeed = 0; - setTimeout(() => { - started = true; - }, 150) - } - - carshb = document.getElementById("car1").getBoundingClientRect(); hitbox = document.getElementById("car0").getBoundingClientRect(); var overlap = !(carshb.right < hitbox.left || @@ -160,6 +96,7 @@ startHooks.push(() => { if (location.search === "?sp") { scenar("wall2", "angry"); } + car1collisionon = false; Sound.crash(); document.getElementById("car1").style.left = car1startx + "px"; document.getElementById("car1").style.top = car1starty + "px"; @@ -168,6 +105,9 @@ startHooks.push(() => { spreadOil(item); }) car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } } @@ -222,4 +162,78 @@ startHooks.push(() => { } }, 200) + setInterval(() => { + if (!car1collisionon) { return; } + + carshb = document.getElementById("car1").getBoundingClientRect(); + hitbox = document.getElementById("arrival").getBoundingClientRect(); + + var overlap = !(carshb.right < hitbox.left || + carshb.left > hitbox.right || + carshb.bottom < hitbox.top || + carshb.top > hitbox.bottom) + + if (overlap && started) { + started = false; + if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 4) { + info("CarManager:car1", "New lap"); + Array.from(document.getElementById('oil').children).forEach((item) => { + spreadOil(item); + }) + if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 3) { + Sound.pass() + } else { + Sound.last() + } + document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); + if (location.search === "?sp") { + if ((document.getElementById('laps-car0').innerText.split("/")[0] - 1 + 1) > (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1)) { + scenar("ahead1", "angry"); + } else { + scenar("ahead2", "happy"); + } + } + } else { + info("CarManager:car1", "Car won the game"); + if (location.search === "?sp") { + scenar("won2", "happy"); + } + require('electron').ipcRenderer.send('addstats', { catalog: "results", key: "loses", add: 1 }); + try { document.getElementById('music').src = "about:blank"; } catch (e) { console.error(e); } + Sound.win(); + keysEnabled = false; + car1cspeed = 0; + car1speed = 0; + document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); + $("#box").fadeOut(500); + setTimeout(() => { + setTimeout(() => { + if (location.search === "?sp" || (online && role === "guest")) { + if (online) {} else { + location.href = "win.html?sp#car1"; + } + } else { + location.href = "win.html#car1"; + } + }, 3500) + }, 3000) + } + car1collisionon = false; + Sound.crash(); + document.getElementById("car1").style.left = car1startx + "px"; + document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; + Array.from(document.getElementById('oil').children).forEach((item) => { + spreadOil(item); + }) + car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) + setTimeout(() => { + started = true; + }, 150) + } + }, 20) + })
\ No newline at end of file diff --git a/race/pause.js b/race/pause.js index d1ee002..92a78a6 100644 --- a/race/pause.js +++ b/race/pause.js @@ -27,7 +27,6 @@ startHooks.push(() => { paused = true; document.getElementById('box').classList.add('paused'); $("#paused").show(); - $("#credits").show(); } else { if (location.search === "?sp") { require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[0]; @@ -53,7 +52,6 @@ startHooks.push(() => { paused = false; document.getElementById('box').classList.remove('paused'); $("#paused").hide(); - $("#credits").hide(); } } |