1
0
forked from noxious/client

Map object depth calculation adjustment

This commit is contained in:
Andrei 2025-02-02 14:39:21 -06:00
parent 554497ecbc
commit 90d7252784
2 changed files with 3 additions and 3 deletions

View File

@ -24,7 +24,7 @@ const imageProps = computed(() => ({
alpha: mapEditor.movingPlacedObject.value?.id == props.placedMapObject.id ? 0.5 : 1, alpha: mapEditor.movingPlacedObject.value?.id == props.placedMapObject.id ? 0.5 : 1,
tint: mapEditor.selectedPlacedObject.value?.id == props.placedMapObject.id ? 0x00ff00 : 0xffffff, tint: mapEditor.selectedPlacedObject.value?.id == props.placedMapObject.id ? 0x00ff00 : 0xffffff,
depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY, props.placedMapObject.mapObject.frameWidth, props.placedMapObject.mapObject.frameHeight), depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY, props.placedMapObject.mapObject.frameWidth, props.placedMapObject.mapObject.frameHeight),
...calculateObjectPlacement(props.placedMapObject,false), ...calculateObjectPlacement(props.placedMapObject),
flipX: props.placedMapObject.isRotated, flipX: props.placedMapObject.isRotated,
texture: props.placedMapObject.mapObject.id, texture: props.placedMapObject.mapObject.id,
originX: props.placedMapObject.mapObject.originX, originX: props.placedMapObject.mapObject.originX,

View File

@ -68,11 +68,11 @@ export function createTileArray(width: number, height: number, tile: string = 'b
} }
export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0, isCharacter: boolean = false) => { export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0, isCharacter: boolean = false) => {
const baseDepth = positionX + positionY const baseDepth = Math.max(positionX, positionY)
if (isCharacter) { if (isCharacter) {
return baseDepth // @TODO: Fix collision, this is a hack return baseDepth // @TODO: Fix collision, this is a hack
} }
return baseDepth + (width + height) / (2 * config.tile_size.width) return (baseDepth + height) / (config.tile_size.width * 2)
} }
async function getTiles(tiles: TileT[], scene: Phaser.Scene) { async function getTiles(tiles: TileT[], scene: Phaser.Scene) {