diff options
author | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-09 00:51:46 +0200 |
---|---|---|
committer | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-09 00:51:46 +0200 |
commit | b9e7ec33542bb8041857eb997d17b29ffeae40c8 (patch) | |
tree | b90eed32c2acdc79f2f362ee031e762983195bfd | |
parent | 8886d5111aa4ae75f54f46c93f09fa7548979969 (diff) | |
download | kartik-client-b9e7ec33542bb8041857eb997d17b29ffeae40c8.tar.gz kartik-client-b9e7ec33542bb8041857eb997d17b29ffeae40c8.tar.bz2 kartik-client-b9e7ec33542bb8041857eb997d17b29ffeae40c8.zip |
Add cooldown to rotations
This helps fix some bugs such as an out of border usebug and a bug that enables players to count a lap as they die. This also makes the game more realistic by removing the possibility of doing moves that are not supposed to be possible in real life.
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | race/cars/keymap.js | 170 | ||||
-rw-r--r-- | views/script/game_debug.js | 4 |
3 files changed, 93 insertions, 83 deletions
diff --git a/package.json b/package.json index 73a4ee2..11e0311 100644 --- a/package.json +++ b/package.json @@ -1 +1 @@ -{"name":"kartik","version":"21.06.15","channel":"stable","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","systeminformation":"^5.7.7","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"}
\ No newline at end of file +{"name":"kartik","version":"a69a90e","channel":"git","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","systeminformation":"^5.7.7","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"}
\ No newline at end of file diff --git a/race/cars/keymap.js b/race/cars/keymap.js index 221a7ec..d1fdf24 100644 --- a/race/cars/keymap.js +++ b/race/cars/keymap.js @@ -24,108 +24,116 @@ startHooks.push(() => { info("GameWindow", "Hitboxes shown"); } } - if (e.keyCode === 90 || e.keyCode === 87 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 38)) { // Z - if (car0cspeed < car0speed) { - car0cspeed = car0cspeed + 0.2; - } - if (document.getElementById("car0").style.transform !== "rotate(-90deg)") { - require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); - document.getElementById("car0").style.transform = "rotate(-90deg)"; - car0collisionon = false; - setTimeout(() => { - car0collisionon = true; - }, 500) - } - } - if (e.keyCode === 83 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 40)) { // S - if (car0cspeed < car0speed) { - car0cspeed = car0cspeed + 0.2; - } - if (document.getElementById("car0").style.transform !== "rotate(90deg)") { - require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); - document.getElementById("car0").style.transform = "rotate(90deg)"; - car0collisionon = false; - setTimeout(() => { - car0collisionon = true; - }, 500) - } - } - if (e.keyCode === 81 || e.keyCode === 65 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 37)) { // Q - if (car0cspeed < car0speed) { - car0cspeed = car0cspeed + 0.2; - } - if (document.getElementById("car0").style.transform !== "rotate(180deg)") { - require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); - document.getElementById("car0").style.transform = "rotate(180deg)"; - car0collisionon = false; - setTimeout(() => { - car0collisionon = true; - }, 500) - } - } - if (e.keyCode === 68 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 39)) { // D - if (car0cspeed < car0speed) { - car0cspeed = car0cspeed + 0.2; - } - if (document.getElementById("car0").style.transform !== "rotate(0deg)") { - require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); - document.getElementById("car0").style.transform = "rotate(0deg)"; - car0collisionon = false; - setTimeout(() => { - car0collisionon = true; - }, 500) - } - } - if (location.search !== "?sp" && location.search !== "?online") { - if (e.keyCode === 38) { // up - if (car1cspeed < car1speed) { - car1cspeed = car1cspeed + 0.2; + + // Car 0 + if (car0collisionon) { + if (e.keyCode === 90 || e.keyCode === 87 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 38)) { // Z + if (car0cspeed < car0speed) { + car0cspeed = car0cspeed + 0.2; } - if (document.getElementById("car1").style.transform !== "rotate(-90deg)") { - document.getElementById("car1").style.transform = "rotate(-90deg)"; - car1collisionon = false; + if (document.getElementById("car0").style.transform !== "rotate(-90deg)") { + require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); + document.getElementById("car0").style.transform = "rotate(-90deg)"; + car0collisionon = false; setTimeout(() => { - car1collisionon = true; + car0collisionon = true; }, 500) } } - if (e.keyCode === 40) { // down - if (car1cspeed < car1speed) { - car1cspeed = car1cspeed + 0.2; + if (e.keyCode === 83 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 40)) { // S + if (car0cspeed < car0speed) { + car0cspeed = car0cspeed + 0.2; } - if (document.getElementById("car1").style.transform !== "rotate(90deg)") { - document.getElementById("car1").style.transform = "rotate(90deg)"; - car1collisionon = false; + if (document.getElementById("car0").style.transform !== "rotate(90deg)") { + require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); + document.getElementById("car0").style.transform = "rotate(90deg)"; + car0collisionon = false; setTimeout(() => { - car1collisionon = true; + car0collisionon = true; }, 500) } } - if (e.keyCode === 37) { // left - if (car1cspeed < car1speed) { - car1cspeed = car1cspeed + 0.2; + if (e.keyCode === 81 || e.keyCode === 65 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 37)) { // Q + if (car0cspeed < car0speed) { + car0cspeed = car0cspeed + 0.2; } - if (document.getElementById("car1").style.transform !== "rotate(180deg)") { - document.getElementById("car1").style.transform = "rotate(180deg)"; - car1collisionon = false; + if (document.getElementById("car0").style.transform !== "rotate(180deg)") { + require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); + document.getElementById("car0").style.transform = "rotate(180deg)"; + car0collisionon = false; setTimeout(() => { - car1collisionon = true; + car0collisionon = true; }, 500) } } - if (e.keyCode === 39) { // right - if (car1cspeed < car1speed) { - car1cspeed = car1cspeed + 0.2; + if (e.keyCode === 68 || ((location.search === "?sp" || location.search === "?online") && e.keyCode === 39)) { // D + if (car0cspeed < car0speed) { + car0cspeed = car0cspeed + 0.2; } - if (document.getElementById("car1").style.transform !== "rotate(0deg)") { - document.getElementById("car1").style.transform = "rotate(0deg)"; - car1collisionon = false; + if (document.getElementById("car0").style.transform !== "rotate(0deg)") { + require('electron').ipcRenderer.send('addstats', { catalog: "ingame", key: "turns", add: 1 }); + document.getElementById("car0").style.transform = "rotate(0deg)"; + car0collisionon = false; setTimeout(() => { - car1collisionon = true; + car0collisionon = true; }, 500) } } } + + // Car 1 + if (car1collisionon) { + if (location.search !== "?sp" && location.search !== "?online") { + if (e.keyCode === 38) { // up + if (car1cspeed < car1speed) { + car1cspeed = car1cspeed + 0.2; + } + if (document.getElementById("car1").style.transform !== "rotate(-90deg)") { + document.getElementById("car1").style.transform = "rotate(-90deg)"; + car1collisionon = false; + setTimeout(() => { + car1collisionon = true; + }, 500) + } + } + if (e.keyCode === 40) { // down + if (car1cspeed < car1speed) { + car1cspeed = car1cspeed + 0.2; + } + if (document.getElementById("car1").style.transform !== "rotate(90deg)") { + document.getElementById("car1").style.transform = "rotate(90deg)"; + car1collisionon = false; + setTimeout(() => { + car1collisionon = true; + }, 500) + } + } + if (e.keyCode === 37) { // left + if (car1cspeed < car1speed) { + car1cspeed = car1cspeed + 0.2; + } + if (document.getElementById("car1").style.transform !== "rotate(180deg)") { + document.getElementById("car1").style.transform = "rotate(180deg)"; + car1collisionon = false; + setTimeout(() => { + car1collisionon = true; + }, 500) + } + } + if (e.keyCode === 39) { // right + if (car1cspeed < car1speed) { + car1cspeed = car1cspeed + 0.2; + } + if (document.getElementById("car1").style.transform !== "rotate(0deg)") { + document.getElementById("car1").style.transform = "rotate(0deg)"; + car1collisionon = false; + setTimeout(() => { + car1collisionon = true; + }, 500) + } + } + } + } if (e.keyCode === 27 || e.keyCode === 8) { // esc pause(true); } diff --git a/views/script/game_debug.js b/views/script/game_debug.js index edcdc26..1fb2639 100644 --- a/views/script/game_debug.js +++ b/views/script/game_debug.js @@ -194,6 +194,7 @@ setInterval(() => { changedDataLeft += "\n0$: Laps: " + document.getElementById('laps-car0').innerText + "/5"; changedDataLeft += "\n0$: Model: " + selectedModel0; + changedDataLeft += "\n0$: Collision: " + (car0collisionon ? "%true%" : "%false%"); changedDataLeft += "\n\n1$: XY: " + document.getElementById('car1').style.left.split("px")[0] + " / " + document.getElementById('car1').style.top.split("px")[0] @@ -212,6 +213,7 @@ setInterval(() => { changedDataLeft += "\n1$: Laps: " + document.getElementById('laps-car1').innerText + "/5"; changedDataLeft += "\n1$: Model: " + selectedModel1; + changedDataLeft += "\n1$: Collision: " + (car1collisionon ? "%true%" : "%false%"); changedDataLeft += "\n" + oil(0) + oil(1) + oil(2) + oil(3) + oil(4); changedDataLeft += "\n\nMusic: " + i; changedDataLeft += "\nCircuit: " + rand; @@ -252,7 +254,7 @@ setInterval(() => { } catch (e) { console.error(e); } -},1000); +},100); window.addEventListener("load", () => { require('@electron/remote').app.getGPUInfo('complete').then((data) => { |