Clamshell64 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=45627 2D Softbody Attempt <h1>Flexible Softbodies in PICO-8</h1> <p>Hello everyone! I've been using PICO-8 for a while now, but this is my first post on the BBS, and I'd like to share some of the shenanigans I'm doing.<br /> About a year ago, I stumbled upon Walaber's video on how he made Jellycar's physics (<a href="https://www.youtube.com/watch?v=3OmkehAJoyo&amp;ab_channel=WalaberEntertainment">https://www.youtube.com/watch?v=3OmkehAJoyo&amp;ab_channel=WalaberEntertainment</a>) and I thought it was really cool. I also thought It'd be fun to make a softbody system for myself. So I tried and was able to do some fun things with springs and a bit of collision. I had learned a bit about dot and cross products that year in math classes I took, so it was cool to use the stuff I just learned to make a fun program. Up to this point all the softbodies were just springs connected to each other.</p> <p><img style="margin-bottom:16px" border=0 src="/media/45627/softbody_2.gif" alt="" /><img style="margin-bottom:16px" border=0 src="/media/45627/polygon_c_0.gif" alt="" /></p> <p>Then, I tried to implement shape matching (where you link the physical polygon to an invisible &quot;frame&quot; that in turn updates its rotation to the physical polygon's) and everything went downhill.</p> <p><img style="margin-bottom:16px" border=0 src="/media/45627/sfbv3_backup3_0.gif" alt="" /><img style="margin-bottom:16px" border=0 src="/media/45627/sfbv3_backup4_2.gif" alt="" /></p> <p>After that I kind of gave up after trying some more methods of measuring the angle of a soft deformable shape, but nothing worked. At that point I felt kind of silly since it seemed like I was 90% done, but couldn't finish the last part. So I quit, and then came back to it a few months ago.<br /> This time, I cheated and asked ChatGPT how to measure the angle of a polygon relative to its initial rotation. It gave me the little bit of vector math I couldn't figure out myself. I implemented it and it worked!! Go figure. </p> <p><img style="margin-bottom:16px" border=0 src="/media/45627/sfb_r1_1.gif" alt="" /> <img style="margin-bottom:16px" border=0 src="/media/45627/sfb_r1_7.gif" alt="" /></p> <p>After that, I tried adding in collisions, but they still weren't very stable - as you can see above - just like last time. (not sure how to get those to work perfect yet). Friction with other bodies is something I'm going to work on as well. I intend to make a game out of this someday, but for now, I'll just put the cartridge here for you all to play with yourself. Use the mouse &amp; press X to move the shape around. There are instructions in its code if you want to make more shapes. </p> <p>Thanks for reading!</p> <p> <table><tr><td> <a href="/bbs/?pid=145419#p"> <img src="/bbs/thumbs/pico8_cs64_softbodies-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=145419#p"> cs64_softbodies</a><br><br> by <a href="/bbs/?uid=45627"> Clamshell64</a> <br><br><br> <a href="/bbs/?pid=145419#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=141367 https://www.lexaloffle.com/bbs/?tid=141367 Tue, 02 Apr 2024 01:14:36 UTC