fix building opacity

This commit is contained in:
Robin Appelman 2025-06-28 19:38:31 +02:00
commit 066cf9287f

View file

@ -50,14 +50,15 @@ export function Building(props: BuildingProp) {
const transform = () => `translate(${scaledX()} ${scaledY()}) scale(${1 / props.scale})`; const transform = () => `translate(${scaledX()} ${scaledY()}) scale(${1 / props.scale})`;
const rotate = () => `rotate(${270 - props.building.angle})`; const rotate = () => `rotate(${270 - props.building.angle})`;
const alpha = () => props.building.health / maxHealth; const alpha = () => props.building.health / maxHealth();
const imageOpacity = () => props.building.health === 0 ? 0 : (1 + alpha()) / 2;
try { try {
const image = () => getBuildingType(props.building.buildingType); const image = () => getBuildingType(props.building.buildingType);
return <g transform={transform()} return <g transform={transform()}>
opacity={alpha()}>
<circle r={16} stroke-width={1} stroke="white" fill={teamColor()} <circle r={16} stroke-width={1} stroke="white" fill={teamColor()}
opacity={alpha()}/> opacity={alpha()}/>
<image href={image()} className={"player-icon"} height={32} width={32} transform={`translate(-16 -16)`}/> <image href={image()} class="player-icon" height={32} width={32} transform={`translate(-16 -16)`}
opacity={imageOpacity()}/>
<Show when={props.building.angle}> <Show when={props.building.angle}>
<polygon points="-6,14 0, 16 6,14 0,24" fill="white" <polygon points="-6,14 0, 16 6,14 0,24" fill="white"
transform={rotate()}/> transform={rotate()}/>