r!PsAw's Diep.io+ (BIG UPDATE)

autorespawn(auto ad watcher with 2min timer), FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false

当前为 2024-08-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name r!PsAw's Diep.io+ (BIG UPDATE)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description autorespawn(auto ad watcher with 2min timer), FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false
  6. // @author You
  7. // @match https://diep.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //!!!WARNING!!! Ui scale has to be at 0.9x for this script to work//
  14. let ui_scale = document.querySelector("#settings-screen > div > div:nth-child(1) > div > div:nth-child(1) > label > span")
  15. function ui_scale_check(){
  16. if(ui_scale.innerHTML != "-" && ui_scale.innerHTML != null){
  17. if(ui_scale.innerHTML != "0.9x"){
  18. alert("please change your ui_scale to 0.9x in Menu -> Settings");
  19. console.log(ui_scale.innerHTML);
  20. }else{
  21. console.log("no alert");
  22. }
  23. clearInterval(interval_for_ui_scale);
  24. }
  25. }
  26. let interval_for_ui_scale = setInterval(ui_scale_check, 0);
  27.  
  28. //config
  29. var two = canvas.width/window.innerWidth;
  30. var debugboolean = false;
  31. var script_boolean = true;
  32.  
  33. // Mouse coordinates
  34. var uwuX = '0'; var uwuY = '0';
  35. document.addEventListener('mousemove', function(e) {
  36. uwuX = e.clientX;
  37. uwuY = e.clientY;
  38. });
  39.  
  40. //net_predict_movement false
  41. const observer = new MutationObserver((mutationsList, observer) => {
  42. let diep_console = document.getElementById("textInput");
  43. if (diep_console) {
  44. input.execute("net_predict_movement false");
  45. observer.disconnect(); // Stop observing after the element is found and script executed
  46. }
  47. });
  48.  
  49. observer.observe(document.body, { childList: true, subtree: true });
  50.  
  51. //remove privacy settings button and apes.io promo
  52. let ads_removed = false;
  53. function instant_remove(){
  54. let privacy_btn = document.getElementById("cmpPersistentLink");
  55. let apes_btn = document.getElementById("apes-io-promo");
  56. if(apes_btn != null && privacy_btn != null){
  57. privacy_btn.remove();
  58. apes_btn.remove();
  59. console.log("removed buttons, quitting...");
  60. clearInterval(interval);
  61. }
  62. };
  63. let interval = setInterval(instant_remove, 0);
  64.  
  65. //toggle leave game
  66. let active = false;
  67. let s = false;
  68. let ingame_quit_btn = document.getElementById("quick-exit-game");
  69. let app = document.getElementById("app");
  70.  
  71. function check_class(){
  72. if(ingame_quit_btn.classList.contains("shown")){
  73. active = false;
  74. }else if(ingame_quit_btn.classList.contains("hidden")){
  75. active = true;
  76. }
  77. }
  78.  
  79. setInterval(check_class, 300);
  80.  
  81. var toggle_quit_btn = document.createElement('button');
  82. toggle_quit_btn.innerHTML = `leave button active? ${active}`;
  83. toggle_quit_btn.style.color = "white";
  84. toggle_quit_btn.style.position = "fixed";
  85. toggle_quit_btn.style.width = "100px";
  86. toggle_quit_btn.style.height = "50px";
  87. toggle_quit_btn.style.bottom = "20%";
  88. toggle_quit_btn.style.left = "30%";
  89. toggle_quit_btn.style.transform = "translate(-50%, 50%)";
  90. toggle_quit_btn.style.cursor = "pointer";
  91. toggle_quit_btn.style.zIndex = '9999';
  92. toggle_quit_btn.onclick = function() {
  93. s = !s;
  94. toggle_quit_btn.innerHTML = `leave button active? ${active}`;
  95. if(s){
  96. ingame_quit_btn.classList.remove("hidden");
  97. ingame_quit_btn.classList.add("shown");
  98. }else{
  99. ingame_quit_btn.classList.remove("shown");
  100. ingame_quit_btn.classList.add("hidden");
  101. }
  102. }
  103.  
  104. app.appendChild(toggle_quit_btn);
  105.  
  106. //timer for bonus reward
  107. const gameOverScreen = document.getElementById('game-over-screen');
  108. const ad_btn = document.getElementById("game-over-video-ad");
  109. var ad_btn_free = true;
  110.  
  111. const timerDisplay = document.createElement('h1');
  112. timerDisplay.textContent = "Time left to collect next bonus levels: 02:00";
  113. gameOverScreen.appendChild(timerDisplay);
  114.  
  115. let timer;
  116. let totalTime = 120; // 2 minutes in seconds
  117.  
  118. function startTimer() {
  119. clearInterval(timer);
  120. timer = setInterval(function() {
  121. if (totalTime <= 0) {
  122. clearInterval(timer);
  123. timerDisplay.textContent = "00:00";
  124. } else {
  125. totalTime--;
  126. let minutes = Math.floor(totalTime / 60);
  127. let seconds = totalTime % 60;
  128. timerDisplay.textContent =
  129. `Time left to collect next bonus levels: ${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  130. }
  131. }, 1000);
  132. }
  133.  
  134. function resetTimer() {
  135. if(totalTime === 0){
  136. clearInterval(timer);
  137. totalTime = 120; // Reset to 2 minutes
  138. timerDisplay.textContent = "02:00";
  139. }
  140. }
  141.  
  142. // Add event listeners for the buttons
  143. ad_btn.addEventListener('click', check_ad_state);
  144.  
  145. function check_ad_state(){
  146. if(totalTime === 0){
  147. resetTimer();
  148. }else if(totalTime === 120){
  149. ad_btn_free = true;
  150. startTimer();
  151. }else{
  152. ad_btn_free = false;
  153. }
  154. }
  155.  
  156. //autorespawn (easy way)
  157. let ingamescreen = document.getElementById("in-game-screen");
  158. let autorespawn = false;
  159.  
  160. function respawn(){
  161. if(autorespawn){
  162. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  163. return;
  164. }else{
  165. if(totalTime === 120 || totalTime === 0){
  166. ad_btn.click();
  167. }else{
  168. let spawnbtn = document.getElementById("spawn-button");
  169. spawnbtn.click();
  170. }
  171. }
  172. }
  173. }
  174.  
  175. setInterval(respawn, 1000);
  176.  
  177. var toggle_auto_r_btn = document.createElement('button');
  178. toggle_auto_r_btn.innerHTML = `auto respawn active? ${autorespawn}`;
  179. toggle_auto_r_btn.style.backgroundColor = "red";
  180. toggle_auto_r_btn.style.color = "white";
  181. toggle_auto_r_btn.style.position = "fixed";
  182. toggle_auto_r_btn.style.width = "100px";
  183. toggle_auto_r_btn.style.height = "50px";
  184. toggle_auto_r_btn.style.bottom = "20%";
  185. toggle_auto_r_btn.style.left = "35%";
  186. toggle_auto_r_btn.style.transform = "translate(-50%, 50%)";
  187. toggle_auto_r_btn.style.cursor = "pointer";
  188. toggle_auto_r_btn.style.zIndex = '9999';
  189. toggle_auto_r_btn.onclick = function() {
  190. autorespawn = !autorespawn;
  191. toggle_auto_r_btn.innerHTML = `auto respawn active? ${autorespawn}`;
  192. if(autorespawn){
  193. toggle_auto_r_btn.style.backgroundColor = "green";
  194. }else{
  195. toggle_auto_r_btn.style.backgroundColor = "red";
  196. }
  197. }
  198.  
  199. app.appendChild(toggle_auto_r_btn);
  200.  
  201. //copy party link
  202. var copy_p_link_btn = document.createElement('button');
  203. copy_p_link_btn.innerHTML = `copy party link`;
  204. copy_p_link_btn.style.color = "white";
  205. copy_p_link_btn.style.position = "fixed";
  206. copy_p_link_btn.style.width = "100px";
  207. copy_p_link_btn.style.height = "50px";
  208. copy_p_link_btn.style.bottom = "20%";
  209. copy_p_link_btn.style.left = "40%";
  210. copy_p_link_btn.style.transform = "translate(-50%, 50%)";
  211. copy_p_link_btn.style.cursor = "pointer";
  212. copy_p_link_btn.style.zIndex = '9999';
  213. copy_p_link_btn.onclick = function() {
  214. document.getElementById("copy-party-link").click();
  215. }
  216.  
  217. app.appendChild(copy_p_link_btn);
  218.  
  219. //find the current Level (credits to abc)
  220. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  221. apply(fillRect, ctx, [text, x, y, ...blah]) {
  222. if (text.startsWith('Lvl ')) {
  223. currentLevel = text.split(' ')[1];
  224. if(text.split(' ')[3] != undefined){
  225. tanky = text.split(' ')[2] + text.split(' ')[3];
  226. }else{
  227. tanky = text.split(' ')[2]
  228. }
  229. }
  230. fillRect.call(ctx, text, x, y, ...blah);
  231. }
  232. });
  233.  
  234. //Detect AutoFire/AutoSpin
  235. let auto_fire = false;
  236. let auto_spin = false;
  237.  
  238. function f_s(f_or_s){
  239. switch (f_or_s){
  240. case "fire":
  241. auto_fire = !auto_fire;
  242. break
  243. case "spin":
  244. auto_spin = !auto_spin;
  245. break
  246. }
  247. }
  248.  
  249. //Diep Units & fov calculator
  250. //NOTE: I removed spaces between tank names for this script only. Also since glider came out and diepindepth was unupdated it didn't update correctly, I fixed that.
  251.  
  252. /*
  253. =============================================================================
  254. Skid & Noob friendly calculation explained:
  255.  
  256. Read this in order to understand, how the position calculation works.
  257.  
  258. 1. Canvas/window coords
  259. When you load diep.io in a browser window, it also loads a canvas where the game is drawn.
  260. Imagine a piece of paper where you draw things, this is canvas. If you place a pen on that piece of paper, this is html element.
  261. Diep.io uses canvas mainly. Your window and the canvas use different coordinate systems, even tho they appear the same at first:
  262.  
  263. start->x
  264. |
  265. \/
  266. y
  267.  
  268. if x is for example 3 and y is 5, you find the point of your mouse.
  269.  
  270. start->x...
  271. |_________|
  272. \/________|
  273. y_________|
  274. ._________|
  275. ._________|
  276. ._________|
  277. ._________|
  278. ._________HERE
  279.  
  280. the right upper corner of your window is the x limit, called window.innerWidth
  281. the left bottom corner of your window is the y limit, called window.innerHeight
  282.  
  283. canvas is the same, but multiplied by 2. So for x, it's canvas.height = window.innerHeight * 2
  284. same goes for y, canvas.width = window.innerWidth * 2
  285.  
  286. This can work the other way around too. canvas.height/2 = window.innerHeight
  287. and canvas.width/2 = window.innerWidth
  288.  
  289. NOTE: when you use input.mouse(x, y) you're using the canvas coordinate system.
  290.  
  291. 2. DiepUnits
  292. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  293. if you're curious about what l and Fv means, like I was I can tell you now.
  294.  
  295. L stands for your Tank level, that you currently have.
  296. Fv is the fieldFactor. You can find them here for each tank: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json
  297. (The formula from the picture as code: const FOV = (level, fieldFactor) => (.55*fieldFactor)/Math.pow(1.01, (level-1)/2); )
  298.  
  299. Additions:
  300. DiepUnits are used, to draw all entities in game in the right size. For example when you go Ranger, they appear smaller
  301. because your entire ingame map shrinks down, so you see more without changing the size of the canvas or the window.
  302. So if a square is 55 diepunits big and it gets visually smaller, it's still 55 diepunits big.
  303.  
  304. Coordinate system: x*scalingFactor, y*scalingFactor
  305.  
  306. IMPORTANT!!! Note that your Tank is getting additional DiepUnits with every level it grows.
  307. This formula descritbes it's growth
  308. 53 * (1.01 ** (currentLevel - 1));
  309.  
  310. 3. WindowScaling
  311. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  312. (you can use the function given in there, if you don't want to make your own)
  313.  
  314. it's used for all ui elements, like scoreboard, minimap or stats upgrades.
  315. NOTE: It's not used for html Elements, only canvas. So the starting menu or gameover screen aren't part of it.
  316.  
  317. Coordinate system: x*windowScaling(), y*windowScaling()
  318.  
  319. 4. Converting coordinate systems into each other
  320. canvas -> window = a/2 -> b
  321. window -> canvas = a*2 -> b
  322. windowScaling -> window = ( a*windowScaling() )/2 -> b
  323. windowScaling -> canvas = a*windowScaling() - > b
  324. diepUnits -> canvas = a/scalingFactor -> b
  325. diepUnits -> window = ( a/scalingFactor )/2 -> b
  326. window -> diepUnits = ( a*scalingFactor )*2 -> b
  327. canvas -> diepUnits = a*scalingFactor -> b
  328. window -> windowScaling() = ( a*windowScaling() )*2 -> b
  329. canvas -> windowScaling() = a*windowScaling() - > b
  330. diepUnits -> windowScaling() = ( a/scalingFactor ) * fieldFactor -> b
  331. windowScaling()-> diepUnits = ( a/fieldFactor ) * scalingFactor -> b
  332.  
  333. =============================================================================
  334.  
  335. My todo list or fix:
  336.  
  337. - window.resize doesn't check if canvas size changes, but only if the user changes it.
  338.  
  339. For example opening google console changes canvas size, but user didn't change the window.
  340.  
  341. - press 2 keys at the same time
  342.  
  343. - simulate diep.io moving and knockback physics
  344.  
  345. - simulate diep.io bullets
  346.  
  347. - figure out how to simulate mouse click events
  348.  
  349. - add game Tick calculator, for bullets cooldown
  350. -> Mi300 said use 0x00 clientbound packet
  351.  
  352. - Finish bullet speed hybrid tanks
  353.  
  354. - Figure out physics for sniper, Ranger etc.
  355.  
  356. =============================================================================
  357.  
  358. Useful info:
  359.  
  360. -shape sizes:
  361.  
  362. tank lvl 1 size = 53 diep units
  363.  
  364. grid square side length = 50 diep units
  365. square, triangle = 55 diep units
  366. pentagon = 75 diep units
  367. small crasher = 35 diep units
  368. big crasher = 55 diep units
  369. alpha pentagon = 200 diep units
  370.  
  371. =============================================================================
  372. */
  373. var currentLevel = 0;
  374. var lastLevel = 0;
  375. var tanky = "";
  376. let ripsaw_radius;
  377. let fieldFactor = 1.0;
  378. let found = false;
  379. let loltank ;let lolztank;
  380. let diepUnits = 53 * (1.01 ** (currentLevel - 1));
  381. let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (currentLevel - 1) / 2);
  382. let scalingFactor = FOV * windowScaling();
  383. const fieldFactors = [
  384. {tank: "Sniper", factor: 0.899},
  385. {tank: "Overseer", factor: 0.899},
  386. {tank: "Overlord", factor: 0.899},
  387. {tank: "Assassin", factor: 0.8},
  388. {tank: "Necromancer", factor: 0.899},
  389. {tank: "Hunter", factor: 0.85},
  390. {tank: "Stalker", factor: 0.8},
  391. {tank: "Ranger", factor: 0.699},
  392. {tank: "Manager", factor: 0.899},
  393. {tank: "Predator", factor: 0.85},
  394. {tank: "Trapper", factor: 0.899},
  395. {tank: "GunnerTrapper", factor: 0.899},
  396. {tank: "Overtrapper", factor: 0.899},
  397. {tank: "MegaTrapper", factor: 0.899},
  398. {tank: "Tri-Trapper", factor: 0.899},
  399. {tank: "Smasher", factor: 0.899},
  400. {tank: "Landmine", factor: 0.899},
  401. {tank: "Streamliner", factor: 0.85},
  402. {tank: "AutoTrapper", factor: 0.899},
  403. {tank: "Battleship", factor: 0.899},
  404. {tank: "AutoSmasher", factor: 0.899},
  405. {tank: "Spike", factor: 0.899},
  406. {tank: "Factory", factor: 0.899},
  407. {tank: "Skimmer", factor: 0.899},
  408. {tank: "Glider", factor: 0.899},
  409. {tank: "Rocketeer", factor: 0.899},
  410. ]
  411.  
  412. function windowScaling() {
  413. const a = canvas.height / 1080;
  414. const b = canvas.width / 1920;
  415. return b < a ? a : b;
  416. }
  417.  
  418. function calculateFOV(Fv, l) {
  419. const numerator = 0.55 * Fv;
  420. const denominator = Math.pow(1.01, (l - 1) / 2);
  421. if(typeof window.HEAPF32 !== 'undefined' && typeof window.fov !== 'undefined' && window.fov.length > 0){
  422. //use this part, if you have a fov script that can share it's fov value with you
  423. FOV = HEAPF32[fov[0]];
  424. }else{
  425. //use this part if you have no fov script
  426. FOV = numerator / denominator;
  427. }
  428. return FOV;
  429. }
  430.  
  431. function apply_values(FF){
  432. calculateFOV(FF, currentLevel);
  433. scalingFactor = FOV * windowScaling();
  434. ripsaw_radius = diepUnits * scalingFactor;
  435. diepUnits = 53 * (1.01 ** (currentLevel - 1));
  436. }
  437.  
  438. function apply_changes(value){
  439. if(found){
  440. fieldFactor = fieldFactors[value].factor;
  441. loltank = tanky;
  442. lastLevel = currentLevel;
  443. apply_values(fieldFactor);
  444. }else{
  445. if(value === null){
  446. fieldFactor = 1.0;
  447. loltank = "default";
  448. lolztank = tanky;
  449. lastLevel = currentLevel;
  450. apply_values(fieldFactor);
  451. }
  452. }
  453. }
  454.  
  455. function bruteforce_tanks(){
  456. for (let i = 0; i < fieldFactors.length; i++){
  457. if(tanky.includes(fieldFactors[i].tank)){
  458. found = true;
  459. console.log("FOUND TANK " + fieldFactors[i].tank);
  460. apply_changes(i);
  461. break;
  462. }else{
  463. found = false;
  464. if(i < fieldFactors.length - 1){
  465. console.log(`checking tank ${i}`);
  466. }else{
  467. console.log("No Tank was found, resetting to default")
  468. apply_changes(null);
  469. }
  470. }
  471. }
  472. }
  473.  
  474. window.addEventListener("resize", bruteforce_tanks);
  475.  
  476. function check_lvl_change() {
  477. if(lastLevel === currentLevel){
  478. //console.log("level wasn't changed");
  479. }else{
  480. console.log("changed level, bruteforcing");
  481. bruteforce_tanks();
  482. }
  483. }
  484.  
  485. function check_change(){
  486. //console.log("lastLevel: " + lastLevel + " currentLevel: " + currentLevel);
  487. check_lvl_change();
  488. if(loltank != tanky){
  489. if(loltank === "default"){
  490. if(lolztank != tanky){
  491. bruteforce_tanks();
  492. }else{
  493. return;
  494. }
  495. }else{
  496. bruteforce_tanks();
  497. }
  498. }
  499. }
  500.  
  501. setInterval(check_change, 250);
  502.  
  503. //canvas gui
  504. let offsetX = 0;
  505. let offsetY = 0;
  506. //for canvas text height and space between it
  507. let text_startingY = 450*windowScaling();let textAdd = 25*windowScaling();
  508. let selected_box = null;
  509. const boxes = [
  510. {color: "lightblue", LUcornerX: 47, LUcornerY: 67},
  511. {color: "green", LUcornerX: 47+90+13, LUcornerY: 67},
  512. {color: "red", LUcornerX: 47, LUcornerY: 67+90+9},
  513. {color: "yellow", LUcornerX: 47+90+13, LUcornerY: 67+90+9},
  514. {color: "blue", LUcornerX: 47, LUcornerY: 67+((90+9)*2)},
  515. {color: "rainbow", LUcornerX: 47+90+13, LUcornerY: 67+((90+9)*2)}
  516. ]
  517.  
  518. const ctx = canvas.getContext('2d');
  519. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY){
  520. ctx.fillStyle = fcolor;
  521. ctx.lineWidth = lineWidth;
  522. ctx.font = font;
  523. ctx.strokeStyle = scolor;
  524. ctx.strokeText(`${text}`, textX, textY)
  525. ctx.fillText(`${text}`, textX, textY)
  526. }
  527.  
  528. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c){
  529. ctx.beginPath();
  530. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  531. ctx.fillStyle = c;
  532. ctx.fill();
  533. }
  534.  
  535. function ctx_rect(x, y, a, b, c){
  536. ctx.beginPath();
  537. ctx.strokeStyle = c;
  538. ctx.strokeRect(x, y, a, b);
  539. }
  540.  
  541. //use this for game entities
  542. function dot_in_diepunits(diepunits_X, diepunits_Y){
  543. ctx_arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, 5, 0, 2 * Math.PI, false, "lightblue");
  544. }
  545.  
  546. function circle_in_diepunits(diepunits_X, diepunits_Y, diepunits_R, c){
  547. ctx.beginPath();
  548. ctx.arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, diepunits_R*scalingFactor, 0, 2 * Math.PI, false);
  549. ctx.strokeStyle = c;
  550. ctx.stroke();
  551. }
  552.  
  553. //use this for ui elements like upgrades or scoreboard
  554. function dot_in_diepunits_FOVless(diepunits_X, diepunits_Y){
  555. ctx_arc(diepunits_X * windowScaling(), diepunits_Y * windowScaling(), 5, 0, 2 * Math.PI, false, "lightblue");
  556. }
  557.  
  558. function square_for_grid(x, y, a, b, color){
  559. ctx.beginPath();
  560. ctx.rect(x*windowScaling(), y*windowScaling(), a*windowScaling(), b*windowScaling());
  561. ctx.strokeStyle = color;
  562. ctx.stroke();
  563. }
  564.  
  565. function draw_upgrade_grid(){
  566. for(let i = 0; i < boxes.length; i++){
  567. let start_x = (boxes[i].LUcornerX*windowScaling())/2;
  568. let start_y = (boxes[i].LUcornerY*windowScaling())/2;
  569. let end_x = ((boxes[i].LUcornerX+43*2)*windowScaling())/2;
  570. let end_y = ((boxes[i].LUcornerY+43*2)*windowScaling())/2;
  571. let temp_color = "black";
  572. if(uwuX > start_x && uwuY > start_y && uwuX < end_x && uwuY < end_y){
  573. temp_color = "red";
  574. selected_box = i;
  575. }else{
  576. temp_color = "black";
  577. selected_box = null;
  578. }
  579. square_for_grid(boxes[i].LUcornerX, boxes[i].LUcornerY, 86, 86, temp_color);
  580. }
  581. for(let i = 0; i < boxes.length; i++){
  582. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY);
  583. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43, boxes[i].LUcornerY);
  584. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY);
  585. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY+43);
  586. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY+43*2);
  587. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY+43);
  588. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY+43*2);
  589. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43, boxes[i].LUcornerY+43);
  590. }
  591. }
  592.  
  593. const gradients = ["#94b3d0", "#96b0c7", "#778daa", "#4c7299", "#52596c", "#19254e", "#2d445f", "#172631"];
  594. const tank_group1 = ["Trapper", "Overtrapper", "MegaTrapper", "Tri-Trapper"]; //Traps only
  595. const tank_group2 = ["Tank", "Twin", "TripleShot", "SpreadShot", "PentaShot", "TwinFlank", "TripleTwin", "QuadTank", "OctoTank", "MachineGun", "Sprayer", "Triplet", "FlankGuard"]; //constant bullets [initial speed = 0.699]
  596. //const tank_group3 = ["GunnerTrapper", "AutoTrapper"]; //Traps AND constant bullets (UNFINISHED)
  597. //const tank_group4 = []; //mix of bullets (UNFINISHED)
  598. //const tank_group5 = ["Sniper", "Assassin", "Stalker", "Ranger"]; //sniper+ bullets (UNFINISHED)
  599. const tank_group6 = ["Destroyer", "Hybrid", "Annihilator"]; //slower bullets [intitial speed = 0.699]
  600. //const tank_group7 = ["Overseer", "Overlord", "Manager", "Necromancer"]; //infinite bullets(drones) (UNFINISHED)
  601. const tank_group8 = ["Factory"]; //drones with spreading abilities
  602. const tank_group9 = ["Battleship"]; //special case
  603.  
  604. function draw_cirle_radius_for_tank(){
  605. if(tank_group1.includes(tanky)){
  606. for(let i = 0; i < gradients.length; i++){
  607. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 485 + (52.5*i), gradients[i]);
  608. }
  609. }else if(tank_group2.includes(tanky)){
  610. for(let i = 0; i < gradients.length; i++){
  611. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1850 + (210*i), gradients[i]);
  612. }
  613. /*
  614. }else if(tank_group5.includes(tanky)){
  615. for(let i = 0; i < gradients.length; i++){
  616. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 2703 + (420*i), gradients[i]);
  617. }*/
  618. }else if(tank_group6.includes(tanky)){
  619. for(let i = 0; i < gradients.length; i++){
  620. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1443.21 + (146.79*i), gradients[i]);
  621. }
  622. /*
  623. }else if(tank_group7.includes(tanky)){
  624. for(let i = 0; i < gradients.length; i++){
  625. circle_in_diepunits( canvas.width/2/scalingFactor , canvas.height/2/scalingFactor, 1607 + (145*i), gradients[i]);
  626. circle_in_diepunits( uwuX*2/scalingFactor , uwuY*2/scalingFactor, 1607 + (145*i), gradients[i]);
  627. }*/
  628. }else if(tank_group8.includes(tanky)){
  629. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 200, gradients[0]);
  630. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 800, gradients[1]);
  631. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 900, gradients[2]);
  632. }else if(tank_group9.includes(tanky)){
  633. for(let i = 0; i < gradients.length; i++){
  634. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1640 + (210*i), gradients[i]);
  635. }
  636. }else{
  637. return;
  638. }
  639.  
  640. }
  641.  
  642. //detect gamemode
  643. let gamemode;
  644. function check_gamemode (){
  645. if(!window.gm){
  646. let gamemode_sel_btn = document.querySelector("#gamemode-selector > div > div.selected");
  647. switch(gamemode_sel_btn.getAttribute("value")){
  648. case "ffa":
  649. gamemode = "ffa";
  650. break
  651. case "teams":
  652. gamemode = "2tdm";
  653. break
  654. case "4teams":
  655. gamemode = "4tdm";
  656. break
  657. case "maze":
  658. gamemode = "maze";
  659. break
  660. case "event":
  661. gamemode = "mothership";
  662. break
  663. case "sandbox":
  664. gamemode = "sandbox";
  665. break
  666. }
  667. }else{
  668. gamemode = window.gm;
  669. }
  670. }
  671.  
  672. setInterval(check_gamemode, 100);
  673.  
  674. // Minimap logic
  675. var minimap_elements = [
  676. {name: "minimap", x: 177.5, y: 177.5, width: 162.5, height: 162.5, color: "purple"},
  677. {name: "2tdm Blue Team", x: 177.5, y: 177.5, width: 17.5, height: 162.5, color: "blue"},
  678. {name: "2tdm Red Team", x: 32.5, y: 177.5, width: 17.5, height: 162.5, color: "red"}
  679. ];
  680.  
  681. var m_e_ctx_coords = [
  682. {name: "minimap", startx: null, stary: null, endx: null, endy: null},
  683. {name: "2tdm Blue Team", startx: null, stary: null, endx: null, endy: null},
  684. {name: "2tdm Red Team", startx: null, stary: null, endx: null, endy: null}
  685. ]
  686.  
  687. function draw_minimap(){
  688. switch(gamemode){
  689. case "2tdm":
  690. for(let i = 0; i < minimap_elements.length; i++){
  691.  
  692. //update their realTime position
  693. m_e_ctx_coords[i].startx = canvas.width-( minimap_elements[i].x * windowScaling() );
  694. m_e_ctx_coords[i].starty = canvas.height-( minimap_elements[i].y * windowScaling());
  695. m_e_ctx_coords[i].endx = m_e_ctx_coords[i].startx + minimap_elements[i].width*windowScaling();
  696. m_e_ctx_coords[i].endy = m_e_ctx_coords[i].starty + minimap_elements[i].height*windowScaling();
  697.  
  698. //draw
  699. ctx.beginPath();
  700. ctx.rect(m_e_ctx_coords[i].startx, m_e_ctx_coords[i].starty, minimap_elements[i].width*windowScaling(), minimap_elements[i].height*windowScaling());
  701. ctx.lineWidth = "1";
  702. ctx.strokeStyle = minimap_elements[i].color;
  703. ctx.stroke();
  704. }
  705. break
  706. case "4tdm":
  707. //in developement, coming soon!
  708. break
  709. }
  710. minimap_collision_check();
  711. }
  712.  
  713. let position_on_minimap;
  714. function minimap_collision_check() {
  715. if(window.l_arrow && window.m_arrow){
  716. if (m_e_ctx_coords[0].startx < window.m_arrow.xl &&
  717. m_e_ctx_coords[0].starty < window.m_arrow.yl &&
  718. m_e_ctx_coords[0].endx > window.m_arrow.xl &&
  719. m_e_ctx_coords[0].endy > window.m_arrow.yl) {
  720.  
  721. if (m_e_ctx_coords[1].startx < window.m_arrow.xl &&
  722. m_e_ctx_coords[1].starty < window.m_arrow.yl &&
  723. m_e_ctx_coords[1].endx > window.m_arrow.xl &&
  724. m_e_ctx_coords[1].endy > window.m_arrow.yl) {
  725.  
  726. position_on_minimap = "blue base";
  727. } else if (m_e_ctx_coords[2].startx < window.m_arrow.xl &&
  728. m_e_ctx_coords[2].starty < window.m_arrow.yl &&
  729. m_e_ctx_coords[2].endx > window.m_arrow.xl &&
  730. m_e_ctx_coords[2].endy > window.m_arrow.yl) {
  731.  
  732. position_on_minimap = "red base";
  733. } else {
  734. position_on_minimap = "not in the base";
  735. }
  736. } else {
  737. position_on_minimap = "Warning! not on minimap";
  738. }
  739.  
  740. console.log(position_on_minimap);
  741. }else{
  742. console.warn("missing arrow script");
  743. }
  744. }
  745.  
  746. //drawing the limit of the server (needs rework)
  747. function draw_server_border(a, b){
  748. ctx.beginPath();
  749. ctx.rect(canvas.width/2 - (a/2*scalingFactor), canvas.height/2 - (b/2*scalingFactor), a*scalingFactor, b*scalingFactor);
  750. ctx.strokeStyle = "red";
  751. ctx.stroke();
  752. }
  753.  
  754. const circle_gradients = [
  755. "#FF0000",// Red
  756. "#FF4D00",// Orange Red
  757. "#FF8000",// Orange
  758. "#FFB300",// Dark Goldenrod
  759. "#FFD700",// Gold
  760. "#FFEA00",// Yellow
  761. "#D6FF00",// Light Yellow Green
  762. "#A3FF00",// Yellow Green
  763. "#6CFF00",// Lime Green
  764. "#00FF4C",// Medium Spring Green
  765. "#00FF9D",// Turquoise
  766. "#00D6FF",// Sky Blue
  767. "#006CFF",// Blue
  768. "#0000FF"// Dark Blue
  769. ];
  770.  
  771. function draw_crx_events(){
  772. //you need either leader arrow or moveTo/lineTo script from h3llside for this part
  773. if(window.y_and_x){
  774. for(let i = 0; i < window.y_and_x.length; i++){
  775. ctx_arc(window.y_and_x[i][0], window.y_and_x[i][1], 10, 0, 2 * Math.PI, false, circle_gradients[i]);
  776. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", i, window.y_and_x[i][0], window.y_and_x[i][1]);
  777. }
  778. }else if(window.l_arrow && window.m_arrow){
  779. //ctx_arc(window.l_arrow.xm, window.l_arrow.ym, 15, 0, 2 * Math.PI, false, window.l_arrow.color);
  780. //ctx_arc(window.m_arrow.xm, window.m_arrow.ym, 1, 0, 2 * Math.PI, false, "yellow");
  781. ctx_arc(window.l_arrow.xl, window.l_arrow.yl, 5, 0, 2 * Math.PI, false, window.l_arrow.color);
  782. ctx_arc(window.m_arrow.xl, window.m_arrow.yl, 1, 0, 2 * Math.PI, false, "yellow");
  783. }
  784. }
  785.  
  786. setTimeout(() => {
  787. let gui = () => {
  788. if(script_boolean){
  789. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  790. if(debugboolean){
  791. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "canvas Lvl:" + currentLevel, canvas.width/20 + 10, text_startingY + (textAdd*0));
  792. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "canvas tank: " + tanky, canvas.width/20 + 10, text_startingY + (textAdd*1));
  793. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width/20 + 10, text_startingY + (textAdd*2));
  794. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "field Factor: " + fieldFactor, canvas.width/20 + 10, text_startingY + (textAdd*3));
  795. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "diep Units: " + diepUnits, canvas.width/20 + 10, text_startingY + (textAdd*4));
  796. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "Fov: " + FOV, canvas.width/20 + 10, text_startingY + (textAdd*5));
  797. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "current Tick: " + currentTick, canvas.width/20 + 10, text_startingY + (textAdd*6));
  798. //ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX + "realY: " + uwuY + "newX: " + uwuX*windowScaling() + "newY: " + uwuY*windowScaling(), uwuX*2, uwuY*2);
  799.  
  800. //points at mouse
  801. ctx_arc(uwuX*two, uwuY*two, 5, 0, 2 * Math.PI, false, "purple");
  802. ctx_rect(uwuX*two, uwuY*two, 41, 36);
  803. /*
  804. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 35, "pink");
  805. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 55, "yellow");
  806. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 75, "purple");
  807. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 200, "blue");
  808. */
  809.  
  810. //coords at mouse
  811. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX*two + "realY: " + uwuY*two, uwuX*two, uwuY*two);
  812. }
  813.  
  814. if(currentLevel != null && tanky != null){
  815. if(debugboolean){
  816. ctx.beginPath();
  817. ctx.moveTo(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
  818. ctx.lineTo(uwuX*two, uwuY*two);
  819. ctx.stroke();
  820. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
  821. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius*0.9, 0, 2 * Math.PI, false, "lightblue");
  822. draw_upgrade_grid();
  823. //draw_server_border(4000, 2250);
  824. }
  825. draw_minimap();
  826. draw_crx_events();
  827. draw_cirle_radius_for_tank();
  828. };
  829. }
  830. }
  831. window.requestAnimationFrame(gui);
  832. }
  833. gui();
  834. setTimeout(() => {
  835. gui();
  836. },5000);
  837. }, 1000);
  838.  
  839. //game ticks finder
  840. let clearRect_count = 0;
  841. let fps;
  842. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  843. apply(fillRect, ctx, [text, x, y, ...blah]) {
  844. if (text.endsWith('FPS')) {
  845. fps = text.split(' ')[0];
  846. }
  847. fillRect.call(ctx, text, x, y, ...blah);
  848. }
  849. });
  850.  
  851. // Tick tracking
  852. let currentTick = 0;
  853. const tickQueue = [];
  854. const everyTickFunctions = [];
  855.  
  856. function runEveryTick(callback) {
  857. everyTickFunctions.push(callback);
  858. }
  859.  
  860. CanvasRenderingContext2D.prototype.clearRect = new Proxy(CanvasRenderingContext2D.prototype.clearRect, {
  861. apply(target, thisArg, argumentsList) {
  862. clearRect_count += 1;
  863. currentTick = Math.floor(clearRect_count / 6);
  864. processTickQueue();
  865. everyTickFunctions.forEach(func => func(currentTick));
  866. return target.apply(thisArg, argumentsList);
  867. }
  868. });
  869.  
  870. function scheduleAfterTicks(callback, ticksToWait) {
  871. const executionTick = currentTick + ticksToWait;
  872. tickQueue.push({ callback, executionTick });
  873. }
  874.  
  875. function processTickQueue() {
  876. while (tickQueue.length > 0 && tickQueue[0].executionTick <= currentTick) {
  877. const item = tickQueue.shift();
  878. item.callback();
  879. }
  880. }
  881.  
  882. // Function to run code for a specified number of ticks
  883. function runForTicks(callback, totalTicks) {
  884. const startingTick = currentTick;
  885. let ticksPassed = 0;
  886.  
  887. function tickHandler() {
  888. if (ticksPassed < totalTicks) {
  889. callback(ticksPassed, currentTick);
  890. ticksPassed++;
  891. scheduleAfterTicks(tickHandler, 1);
  892. }
  893. }
  894.  
  895. tickHandler(); // Start the process
  896. }
  897.  
  898. // Example usage:
  899. function test() {
  900. console.log("Starting test at tick:", currentTick);
  901.  
  902. scheduleAfterTicks(() => {
  903. console.log("150 ticks have passed, current tick:", currentTick);
  904. // Add your code here
  905. }, 150);
  906. }
  907.  
  908. function testLoop() {
  909. console.log("Starting testLoop at tick:", currentTick);
  910. runForTicks((ticksPassed, currentTick) => {
  911. console.log(`Tick passed: ${ticksPassed}, Current tick: ${currentTick}`);
  912. // Add any other code you want to run each tick
  913. }, 50);
  914. }
  915.  
  916. //cooldowns
  917. let c_cd = "red";
  918. let c_r = "green";
  919. const cooldowns = [
  920. {Tank: "Destroyer", cooldown0: 109, cooldown1: 94, cooldown2: 81, cooldown3: 86},
  921. ]
  922.  
  923. //detect which slot was clicked
  924. document.addEventListener('mousedown', checkPos)
  925. function checkPos(e){
  926. console.log(currentTick);
  927. console.log(boxes[selected_box]);
  928. }
  929.  
  930.  
  931. //warns you about annis, destroyers
  932. /*
  933. function drawTheThing(x,y,r) {
  934. if(script_boolean){
  935. let a = ctx.fillStyle;
  936. ctx.fillStyle = "#FF000044";
  937. ctx.beginPath();
  938. ctx.arc(x,y,4*r,0,2*Math.PI);
  939. ctx.fill();
  940. ctx.fillStyle = "#FF000066";
  941. ctx.beginPath();
  942. ctx.arc(x,y,2*r,0,2*Math.PI);
  943. ctx.fill();
  944. ctx.beginPath();
  945. }
  946. }
  947. var angle,a,b,width;
  948. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  949. apply(target, thisArgs, args) {
  950. //console.log(thisArgs)
  951. if (Math.abs(args[0]/args[3]).toFixed(3) == (95/71.4).toFixed(3) || Math.abs(args[0]/args[3]).toFixed(3) == (95/96.6).toFixed(3)) {
  952. angle = Math.atan2(args[2],args[3]) || 0;
  953. width = Math.hypot(args[3], args[2]);
  954. a = args[4]-Math.cos(angle+Math.PI/2)*width/2;
  955. b = args[5]+Math.sin(angle+Math.PI/2)*width/2;
  956. drawTheThing(a,b, Math.hypot(args[3],args[2]));
  957. }
  958. return Reflect.apply(target, thisArgs, args);
  959. }
  960. });
  961. */
  962.  
  963. //physics for movement (UNFINISHED)
  964. /*
  965. //movement speed ingame stat
  966. let m_s = [0, 1, 2, 3, 4, 5, 6, 7];
  967.  
  968. function accelarate(A_o){
  969. //Accelaration
  970. let sum = 0;
  971. runForTicks((ticksPassed, currentTick) => {
  972. console.log("sum is being calculated...");
  973. sum += A_o * Math.pow(0.9, ticksPassed - 1);
  974. offsetX = Math.floor(sum * scalingFactor);
  975. console.log(offsetX);
  976. }, 50);
  977. //decelerate(sum);
  978. }
  979.  
  980. function decelerate(sum){
  981. //deceleration
  982. let res = 0;
  983. runForTicks((ticksPassed, currentTick) => {
  984. console.log("res is being calculated...");
  985. res = sum * Math.pow(0.9, ticksPassed);
  986. offsetX = Math.floor(res * scalingFactor);
  987. console.log(offsetX);
  988. }, 50);
  989. }
  990. function calculate_speed(movement_speed_stat){
  991. console.log("calculate_speed function called");
  992. //use Accelaration for first 50 ticks, then deceleration until ticks hit 100, then stop moving
  993.  
  994. //calculating base value, we'll need this later
  995. let a = (1.07**movement_speed_stat);
  996. let b = (1.015**(currentLevel - 1));
  997. let A_o = 2.55*(a/b);
  998. accelarate(A_o);
  999. }
  1000. */
  1001.  
  1002. //handle Key presses
  1003. let key_storage = [];
  1004.  
  1005. function AntiAfkTimeout(){
  1006. window.requestAnimationFrame(AntiAfkTimeout);
  1007. if(key_storage.length === 0){
  1008. input.key_down(87);
  1009. input.key_down(83);
  1010. input.key_up(87);
  1011. input.key_up(83);
  1012. }
  1013. }
  1014. window.requestAnimationFrame(AntiAfkTimeout);
  1015.  
  1016. document.onkeydown = function(e) {
  1017. if(!key_storage.includes(e.key)){
  1018. key_storage.push(e.key);
  1019. }
  1020. console.log(key_storage);
  1021. analyse_keys();
  1022. }
  1023.  
  1024. document.onkeyup = function(e) {
  1025. if(key_storage.includes(e.key)){
  1026. key_storage.splice(key_storage.indexOf(e.key), 1);
  1027. }
  1028. console.log(key_storage);
  1029. analyse_keys();
  1030. }
  1031.  
  1032. function analyse_keys(){
  1033. if(key_storage.includes("j")){ //J
  1034. script_boolean = !script_boolean;
  1035. }else if(key_storage.includes("b")){ //B
  1036. debugboolean = !debugboolean;
  1037. }else if(key_storage.includes("n")){
  1038. //calculate_speed(m_s[0]);
  1039. }else if(key_storage.includes("e")){ //E
  1040. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  1041. f_s("fire");
  1042. }else{
  1043. auto_fire = false;
  1044. }
  1045. console.log(auto_fire);
  1046. }else if(key_storage.includes("c")){
  1047. console.log(auto_spin);
  1048. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  1049. f_s("spin");
  1050. }else{
  1051. auto_spin = false;
  1052. }
  1053. console.log(auto_spin);
  1054. }
  1055. }
  1056. // Handle key presses for moving the center (UNFINISHED)
  1057.  
  1058. /*
  1059. function return_to_center(XorY, posOrNeg){
  1060. console.log("function called with: " + XorY + posOrNeg);
  1061. if(XorY === "x"){
  1062. if(posOrNeg === "pos"){
  1063. while(offsetX < 0){
  1064. offsetX += 0.5*scalingFactor;
  1065. }
  1066. }else if(posOrNeg === "neg"){
  1067. while(offsetX > 0){
  1068. offsetX -= 0.5*scalingFactor;
  1069. }
  1070. }else{
  1071. console.log("invalid posOrNeg at return_to_center();")
  1072. }
  1073. }else if(XorY === "y"){
  1074. if(posOrNeg === "pos"){
  1075. while(offsetY < 0){
  1076. offsetY += 0.5*scalingFactor;
  1077. }
  1078. }else if(posOrNeg === "neg"){
  1079. while(offsetY > 0){
  1080. offsetY -= 0.5*scalingFactor;
  1081. }
  1082. }else{
  1083. console.log("invalid posOrNeg at return_to_center();")
  1084. }
  1085. }else{
  1086. console.log("invalid XorY at return_to_center();");
  1087. }
  1088. }
  1089.  
  1090. document.onkeydown = function(e) {
  1091. switch (e.keyCode) {
  1092. case 87: // 'W' key
  1093. console.log("W");
  1094. if(offsetY >= -87.5*scalingFactor){
  1095. offsetY -= 12.5*scalingFactor;
  1096. }
  1097. break
  1098. case 83: // 'S' key
  1099. console.log("S");
  1100. if(offsetY <= 87.5*scalingFactor){
  1101. offsetY += 12.5*scalingFactor;
  1102. }
  1103. break;
  1104. case 68: // 'D' key
  1105. console.log("D");
  1106. if(offsetX <= 87.5*scalingFactor){
  1107. offsetX += 12.5*scalingFactor;
  1108. }
  1109. break
  1110. case 65: // 'A' key
  1111. console.log("A");
  1112. if(offsetX >= -87.5*scalingFactor){
  1113. offsetX -= 12.5*scalingFactor;
  1114. }
  1115. break
  1116. }
  1117. }
  1118.  
  1119. document.onkeyup = function(e) {
  1120. switch (e.keyCode) {
  1121. case 87: // 'W' key
  1122. console.log("W unpressed");
  1123. return_to_center("y", "pos");
  1124. break
  1125. case 83: // 'S' key
  1126. console.log("S unpressed");
  1127. return_to_center("y", "neg");
  1128. break;
  1129. case 68: // 'D' key
  1130. console.log("D unpressed");
  1131. return_to_center("x", "neg");
  1132. break
  1133. case 65:
  1134. console.log("A unpressed");
  1135. return_to_center("x", "pos");
  1136. }
  1137. }
  1138. */