render cart

This commit is contained in:
Robin Appelman 2025-06-26 16:55:55 +02:00
commit a4d835f0c6
9 changed files with 97 additions and 12 deletions

View file

@ -2,14 +2,16 @@ import {Player as PlayerDot} from './Render/Player';
import {Building as BuildingDot} from './Render/Building';
import {Projectile as ProjectileDot} from './Render/Projectile';
import {findMapAlias} from './MapBoundries';
import {PlayerState, Header, WorldBoundaries, BuildingState, ProjectileState} from "./Data/Parser";
import {PlayerState, Header, WorldBoundaries, BuildingState, ProjectileState, CartState} from "./Data/Parser";
import {Show} from "solid-js";
import {Projectile} from "./Render/Cart";
export interface MapRenderProps {
header: Header;
players: PlayerState[];
buildings: BuildingState[];
projectiles: ProjectileState[];
cart: CartState | null;
size: {
width: number;
height: number;
@ -27,6 +29,8 @@ export function MapRender(props: MapRenderProps) {
const image = `${map_root}images/${mapAlias}.webp`;
const background = `url(${image})`;
console.log(props.cart);
return (
<svg class="map-background" width={props.size.width} height={props.size.height}
style={{"background-image": background}}>
@ -73,6 +77,10 @@ export function MapRender(props: MapRenderProps) {
scale={props.scale}/>
</Show>
}</For>
<Show when={props.cart}>
<Projectile cart={props.cart} mapBoundary={props.world} targetSize={props.size}
scale={props.scale}/>
</Show>
</svg>
);
}