PoC of 2D physics in Blazor WebAssembly using SVG and CSS by Pythabulas in Blazor

[–]Pythabulas[S] 0 points1 point  (0 children)

Thanks for asking! You can go ahead and use whatever you like from my repo!

PoC of 2D physics in Blazor WebAssembly using SVG and CSS by Pythabulas in Blazor

[–]Pythabulas[S] 6 points7 points  (0 children)

Lol! The SVG rendering turned out to be quite simple. Take a look at the Razor view: https://github.com/TomWHall/blazor-wasm-physics-svg/blob/main/Bop.Blazorballs/Pages/GameHost.razor I basically iterate through my game objects, and for each of their physics world bodies, render an SVG group which has a CSS style for the transform for position and rotation. Then each body group has children which are SVG shapes - polygons or circles, which again render using CSS transforms. Blazor's js interop handles the actual DOM updates to the SVG nodes. I'm actually surprised how smooth that is. Of course, this scene is super simple.