game-village-politics-frontend/app/components/map/March.vue

58 lines
1.9 KiB
Vue

<script setup lang="ts">
import type { MapMovement } from '~/types/map'
const props = defineProps<{
size: MapMovement['size']
colour: string
/** Walking to the left. */
flip?: boolean
motion?: boolean
}>()
// One to five soldiers by the size tier, in a little column behind a banner bearer.
const COUNT = { tiny: 1, small: 2, medium: 3, large: 4, huge: 5 }
const soldiers = computed(() =>
Array.from({ length: COUNT[props.size] }, (_, i) => ({ x: -i * 9 + (i % 2) * 2, y: (i % 2) * 5, delay: `${-i * 0.18}s` })),
)
</script>
<!-- A group on the march, drawn round its position in a 100-unit box; each soldier steps in place. -->
<template>
<g :transform="flip ? 'scale(-1 1)' : undefined">
<ellipse :cx="-((COUNT[size] - 1) * 9) / 2" cy="12" :rx="10 + COUNT[size] * 5" ry="5" fill="#2b2118" opacity="0.35" />
<g v-for="(s, i) in soldiers" :key="i" :transform="`translate(${s.x} ${s.y})`">
<g :class="motion ? 'step' : ''" :style="{ animationDelay: s.delay }">
<rect x="-3" y="-8" width="6" height="11" :fill="i === 0 ? colour : '#57391f'" />
<rect x="-3" y="3" width="2.4" height="7" fill="#2b2118" class="leg" />
<rect x="0.6" y="3" width="2.4" height="7" fill="#2b2118" class="leg leg-b" />
<circle cy="-12" r="3.6" fill="#d9b48a" />
<line x1="5" y1="-20" x2="5" y2="6" stroke="#4a3b2e" stroke-width="1.6" />
<polygon v-if="i === 0" points="5,-20 16,-17 5,-13" :fill="colour" stroke="#2b2118" stroke-width="0.8" />
</g>
</g>
</g>
</template>
<style scoped>
/* Marching in place: a small bob, legs swapping. Off under reduced motion (no class then). */
.step {
animation: bob 0.55s steps(2) infinite;
}
.step .leg {
animation: swing 0.55s steps(2) infinite;
}
.step .leg-b {
animation-direction: reverse;
}
@keyframes bob {
to {
transform: translateY(-1.6px);
}
}
@keyframes swing {
to {
transform: translateY(-1.2px);
}
}
</style>