Fist Push
This commit is contained in:
parent
dd63653413
commit
cab9de1e90
118 changed files with 364726 additions and 0 deletions
24
server/utils/utilsMath.js
Normal file
24
server/utils/utilsMath.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
const blockSize = 16;
|
||||
|
||||
function decimalToHex(decimalValue) {
|
||||
// Convertit la valeur décimale en hexadécimal
|
||||
let hexString = decimalValue.toString(16).toUpperCase();
|
||||
// Divise la chaîne hexadécimale en deux parties
|
||||
let firstByte = "0x" + hexString.slice(0, -2);
|
||||
let secondByte = "0x" + hexString.slice(-2);
|
||||
return [firstByte, secondByte];
|
||||
}
|
||||
|
||||
function convertInGameLoctoLeafletLoc(landblockId, x, y) {
|
||||
let [lbx, lby] = decimalToHex(landblockId);
|
||||
lbx = lbx * blockSize;
|
||||
lby = lby * blockSize;
|
||||
let locx = lbx + x / 10;
|
||||
let locy = 4080 - (lby + y / 10) - 1;
|
||||
locx = locx / 16;
|
||||
locy = (locy / 16) * -1;
|
||||
// Renvoyer les coordonnées converties
|
||||
return { locx, locy };
|
||||
}
|
||||
|
||||
module.exports = { convertInGameLoctoLeafletLoc };
|
||||
Loading…
Add table
Add a link
Reference in a new issue