Map object isometric placement
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { PlacedMapObject, TextureData } from '@/application/types'
|
||||
import { loadTexture } from '@/composables/gameComposable'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/mapComposable'
|
||||
import { calculateIsometricDepth } from '@/composables/mapComposable'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { Image, useScene } from 'phavuer'
|
||||
import { computed, onMounted } from 'vue'
|
||||
@ -31,22 +31,13 @@ const imageProps = computed(() => ({
|
||||
originY: props.placedMapObject.mapObject.originY
|
||||
}))
|
||||
|
||||
function calculateObjectPlacement(mapObj: PlacedMapObject, tileCenterSnap: boolean) : {x: number; y: number} {
|
||||
let position : {x: number; y: number}
|
||||
if (tileCenterSnap) {
|
||||
let halfTileWidth = config.tile_size.width/2
|
||||
let halfTileHeight = config.tile_size.height/2
|
||||
position = {
|
||||
x: Math.ceil((mapObj.positionX-config.tile_size.height)/halfTileWidth) * halfTileWidth,
|
||||
y: Math.ceil((mapObj.positionY-config.tile_size.height)/halfTileWidth) * halfTileWidth,
|
||||
}
|
||||
}
|
||||
else {
|
||||
position = { x: mapObj.positionX, y: mapObj.positionY }
|
||||
}
|
||||
function calculateObjectPlacement(mapObj: PlacedMapObject) : {x: number; y: number} {
|
||||
let position = { x: mapObj.positionX, y: mapObj.positionY }
|
||||
let halfTileWidth = config.tile_size.width/2
|
||||
let halfTileHeight = config.tile_size.height/2
|
||||
return {
|
||||
x: position.x-mapObj.mapObject.frameWidth/2,
|
||||
y: position.y-mapObj.mapObject.frameHeight/2
|
||||
y: position.y-mapObj.mapObject.frameHeight/2-halfTileHeight
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user