-
-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from feeshmaster/patch-7
Create precisionDrawing.js
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
let precisionDrawing = false | ||
//mod made by feeshmaster | ||
|
||
//try out debugRework.js or any other mods made by me! | ||
document.addEventListener("keydown", (e) => { | ||
if (e.key == "w" && precisionDrawing) { | ||
mousePos.y -= 1 | ||
} else if (e.key == "a" && precisionDrawing) { | ||
mousePos.x -= 1 | ||
} else if (e.key == "s" && precisionDrawing) { | ||
mousePos.y += 1 | ||
} else if (e.key == "d" && precisionDrawing) { | ||
mousePos.x += 1 | ||
} else if (event.key === 'X' && event.shiftKey) { | ||
console.log("precisionMode deactivated!") | ||
precisionDrawing = !precisionDrawing | ||
if (!precisionDrawing) { | ||
mousePos = {x: "not", y: "updated"} | ||
} | ||
} | ||
}) | ||
|
||
setTimeout(setUpOnStart, 1000) | ||
function setUpOnStart() { | ||
|
||
getMousePos = (canvas, evt) => { | ||
if (precisionDrawing) { | ||
return mousePos; | ||
} | ||
// If evt.touches is defined, use the first touch | ||
if (evt.touches) { | ||
evt.preventDefault(); | ||
evt = evt.touches[0]; | ||
isMobile = true; | ||
} | ||
var rect = canvas.getBoundingClientRect(); | ||
return { | ||
// Round to nearest pixel | ||
x: Math.round((evt.clientX - rect.left)/pixelSize-0.5), | ||
y: Math.round((evt.clientY - rect.top)/pixelSize-0.5) | ||
}; | ||
} | ||
|
||
let controlsTable = document.getElementById("controlsTable"); | ||
let row1 = document.createElement("tr"); | ||
row1.innerHTML = `<td colspan="2" style="text-align:center"><strong>Mod controls</strong></td>`; | ||
let row2 = document.createElement("tr"); | ||
row2.innerHTML = `<td>start precision</td><td><kbd>Shift + X</kbd> or <kbd>toggle button(not released)</kbd></td>`; | ||
let row3 = document.createElement("tr"); | ||
row3.innerHTML = `<td>move in precision</td><td><kbd>W, A, S, D/arrows</kbd> or <kbd>buttons(not released)</kbd></td>`; | ||
|
||
// Append the rows | ||
controlsTable.appendChild(row1); | ||
controlsTable.appendChild(row2); | ||
controlsTable.appendChild(row3); | ||
|
||
|
||
} |