forked from public/foundryvtt-reve-de-dragon
Fix calculs coordonnées et distances
Utiliser les différents repères de cases: - coordonnées TMR A5 - oddq pour les coordonnées de case (ligne, colonne) - axial (q,r) pour effectuer les calculs de distance utiliser x, y rend la distinction de positions de pixels vs position dans la grille parfois ardue. Utilisation des coordonnées axiales pour le calcul de distance.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
|
||||
const tooltipStyle = new PIXI.TextStyle({
|
||||
fontFamily: 'CaslonAntique',
|
||||
@ -130,18 +130,18 @@ export class PixiTMR {
|
||||
}
|
||||
}
|
||||
|
||||
setPosition( sprite, pos) {
|
||||
let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
setPosition( sprite, oddq) {
|
||||
let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x;
|
||||
let dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y;
|
||||
sprite.x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) + dx;
|
||||
sprite.y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) + dy + decallagePairImpair;
|
||||
sprite.x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) + dx;
|
||||
sprite.y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) + dy + decallagePairImpair;
|
||||
}
|
||||
|
||||
getCaseRectangle(pos) {
|
||||
let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) - (tmrConstants.cellw / 2);
|
||||
let y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair;
|
||||
getCaseRectangle(oddq) {
|
||||
let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) - (tmrConstants.cellw / 2);
|
||||
let y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair;
|
||||
return { x: x, y: y, w: tmrConstants.cellw, h: tmrConstants.cellh };
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user