about summary refs log blame commit diff stats
path: root/html/rogue/js/utils.js
blob: bd329fba4dbf05063cf893abfb8534c76769b1d6 (plain) (tree)
























                                                  
const Utils = {
    hexToKey(hex) {
        return `${hex.q},${hex.r}`;
    },
    
    keyToHex(key) {
        const [q, r] = key.split(',').map(Number);
        return { q, r };
    },
    
    // Screen/canvas coordinate utilities
    screenToCanvas(x, y, camera) {
        return {
            x: x + camera.x,
            y: y + camera.y
        };
    },
    
    canvasToScreen(x, y, camera) {
        return {
            x: x - camera.x,
            y: y - camera.y
        };
    }
};