1
0
forked from noxious/client
This commit is contained in:
Dennis Postma 2025-02-15 16:51:58 +01:00
parent d8805dd775
commit 337446497b
3 changed files with 4 additions and 10 deletions

View File

@ -61,7 +61,7 @@ function calculateObjectPlacement(mapObj: PlacedMapObject): { x: number; y: numb
const imageProps = computed(() => ({ const imageProps = computed(() => ({
alpha: mapEditor.movingPlacedObject.value?.id == props.placedMapObject.id || mapEditor.selectedMapObject.value?.id == props.placedMapObject.id ? 0.5 : 1, 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, tint: mapEditor.selectedPlacedObject.value?.id == props.placedMapObject.id ? 0x00ff00 : 0xffffff,
depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY, mapObject.value!.frameWidth, mapObject.value!.frameHeight), depth: calculateIsometricDepth(props.placedMapObject.positionX, props.placedMapObject.positionY),
...calculateObjectPlacement(props.placedMapObject), ...calculateObjectPlacement(props.placedMapObject),
flipX: props.placedMapObject.isRotated, flipX: props.placedMapObject.isRotated,
texture: mapObject.value!.id, texture: mapObject.value!.id,

View File

@ -18,7 +18,7 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
const tween = ref<Phaser.Tweens.Tween | null>(null) const tween = ref<Phaser.Tweens.Tween | null>(null)
const updateIsometricDepth = (positionX: number, positionY: number) => { const updateIsometricDepth = (positionX: number, positionY: number) => {
isometricDepth.value = calculateIsometricDepth(positionX, positionY, 30, 95) isometricDepth.value = calculateIsometricDepth(positionX, positionY)
} }
const updatePosition = (positionX: number, positionY: number) => { const updatePosition = (positionX: number, positionY: number) => {

View File

@ -62,14 +62,8 @@ export function createTileArray(width: number, height: number, tile: string = 'b
return Array.from({ length: height }, () => Array.from({ length: width }, () => tile)) return Array.from({ length: height }, () => Array.from({ length: width }, () => tile))
} }
export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0) => { export const calculateIsometricDepth = (positionX: number, positionY, pivotPoints: { x: number; y: number; }[] = []) => {
const backCornerX = positionX + width return Math.max(positionX + positionY);
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) { async function loadTileTextures(tiles: TileT[], scene: Phaser.Scene) {