From d0af83ec6019450911d447cade786a95f61ccbab Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Fri, 14 Feb 2025 23:15:35 +0100 Subject: [PATCH] N/A --- .../game/map/partials/PlacedMapObject.vue | 2 +- src/services/mapService.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/game/map/partials/PlacedMapObject.vue b/src/components/game/map/partials/PlacedMapObject.vue index 74eeabc..9e3a4cd 100644 --- a/src/components/game/map/partials/PlacedMapObject.vue +++ b/src/components/game/map/partials/PlacedMapObject.vue @@ -61,7 +61,7 @@ function calculateObjectPlacement(mapObj: PlacedMapObject): { x: number; y: numb const imageProps = computed(() => ({ alpha: mapEditor.movingPlacedObject.value?.id == props.placedMapObject.id || mapEditor.selectedMapObject.value?.id == props.placedMapObject.id ? 0.5 : 1, tint: mapEditor.selectedPlacedObject.value?.id == props.placedMapObject.id ? 0x00ff00 : 0xffffff, - depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY, mapObject.value!.frameWidth, mapObject.value!.frameHeight, mapObject.value!.originX, mapObject.value!.originY), + depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY, mapObject.value!.frameWidth, mapObject.value!.frameHeight), ...calculateObjectPlacement(props.placedMapObject), flipX: props.placedMapObject.isRotated, texture: mapObject.value!.id, diff --git a/src/services/mapService.ts b/src/services/mapService.ts index 793faf5..c984b3a 100644 --- a/src/services/mapService.ts +++ b/src/services/mapService.ts @@ -62,12 +62,14 @@ export function createTileArray(width: number, height: number, tile: string = 'b return Array.from({ length: height }, () => Array.from({ length: width }, () => tile)) } -export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0, isCharacter: boolean = false) => { - const baseDepth = positionX + positionY - if (isCharacter) { - return baseDepth - } - return baseDepth + (width + height) / (2 * config.tile_size.width) +export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0) => { + const backCornerX = positionX + width + const backCornerY = positionY + height + + const sortingX = (positionX + backCornerX) / 2 + const sortingY = (positionY + backCornerY) / 2 + + return sortingX + sortingY } async function loadTileTextures(tiles: TileT[], scene: Phaser.Scene) {