Hi, I'm trying to build a simple 2D-physics engine...
# korge
Hi, I'm trying to build a simple 2D-physics engine, but for huge numbers of objects realtime-Physics are not a good concept. So I had the idea to pre-calculate a full simulation and save the data of every object and every frame in a text file. Then I wanted to read the text-data with korge (for example like .xml) and recreate all frames by creating the objects in korGE and move them as the text file describes it. So actually I want to create every frame with graphical objects in korge, take a "screenshot" of the actual situation and save it as png. After doing that for all frames, the images are put into an animated .gif, and so you can watch the full physics-simulation. But how is it possible to create objects in korge and then save the actual screen as .png? Or is there maybe a better way to do non-realtime-physics-simulation?
You can create a screenshot of a View like this: https://github.com/korlibs/korge/blob/cd586ad1fc0bb1ff1f5c8d783157b6d957885b19/kor[…]c/commonMain/kotlin/com/soywiz/korge/view/ViewRenderToBitmap.kt So you can for example get the Stage instance and call
then you can write that Bitmap into a file with:
bitmap.writeTo(localvfs("/tmp/file.png"), PNG)
Thank you, it works perfect
👍 1