shanecelis [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=47628 Introducing eXtended Position Based Dynamics (XPBD) library <h1> <table><tr><td> <a href="/bbs/?pid=136950#p"> <img src="/bbs/thumbs/pico8_xpbd-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=136950#p"> xpbd</a><br><br> by <a href="/bbs/?uid=47628"> shanecelis</a> <br><br><br> <a href="/bbs/?pid=136950#p"> [Click to Play]</a> </td></tr></table> </h1> <h1>Library</h1> <p>This is a library to simulate physics using the eXtended Position Based Dynamics (XPBD) methodology.</p> <h2>xpbd.p8</h2> <ul> <li>page 0, library - 1368 tokens</li> <li>page 1, demo - 698 tokens</li> </ul> <h1>Demo</h1> <p>It contains the following demos you can access with the left and right keys:</p> <ul> <li>a single bead on a ring;</li> <li>multiple beads on a ring;</li> <li>a squishy square;</li> <li>and an about page with particles.</li> </ul> <p>The bead examples are ports of Matthias Muller's <a href="https://matthias-research.github.io/pages/tenMinutePhysics/index.html">ten minute physics</a> examples.</p> <h1>Usage</h1> <p>Include the first page for the library contents without any demo code.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>#include xpbd.p8:0 function _init() local a = particle:new { pos = vec(64, 64) } } local b = particle:new { pos = vec(74, 64) } } sim = xpbd:new { particles = { a, b }, constraints = { distance_constraint:new { rest_length = 10, a, b } } } end function _update() sim:update() end function _draw() sim:draw() end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>See demos for how to setup.</p> <h1>Bugs</h1> <ul> <li>I have not optimized the token count yet.</li> <li>Collision resolution is not well worked out yet.</li> </ul> <h2>Questions</h2> <p>I'm curious if you could use XPBD to make a platformer that <em>felt</em> right. Maybe if it was stiff and used just a one step solver. I have serious doubts but would be fun to see.</p> <h1>License</h1> <p>Copyright (c) 2023 <a href="https://mastodon.gamedev.place/%40shanecelis">Shane Celis</a><br /> Released under the <a href="https://opensource.org/licenses/MIT">MIT license</a></p> <h1>Acknowlegments</h1> <p>Many thanks to Matthias Muller and his collaborators for XPBD papers, code, examples, and videos that illucidate a refreshingly simple way to simulate physics.</p> https://www.lexaloffle.com/bbs/?tid=54905 https://www.lexaloffle.com/bbs/?tid=54905 Sun, 05 Nov 2023 09:05:43 UTC keyboard-lemons library and demo <p>keyboard-lemons.p8</p> <ul> <li>page 1, library - 181 tokens</li> <li>page 2, demo - 301 tokens</li> </ul> <p>This cart is principally a library for interacting with the user in a query and response format using the keyboard.</p> <h1>Usage</h1> <p>You can include the library in your own cart by including only the first page:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>#include keyboard-lemons.p8:1</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>The second page includes a demo with an old kids' game called lemons. The most salient feature is that user queries can be written straightfowardly:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>answer = prompt(&quot;what's 2+2? &quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>The magic&mdash;as it often does&mdash;lies in a little thing called coroutines.</p> <h1>Demo</h1> <p> <table><tr><td> <a href="/bbs/?pid=136428#p"> <img src="/bbs/thumbs/pico8_keyboard_lemons-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=136428#p"> keyboard_lemons</a><br><br> by <a href="/bbs/?uid=47628"> shanecelis</a> <br><br><br> <a href="/bbs/?pid=136428#p"> [Click to Play]</a> </td></tr></table> <br /> This is actually one of the first computer games I ever wrote, back then in gw-basic. It was a silly <a href="https://www.wikihow.com/Play-Lemons">pen-and-paper game</a> I had learned that I decided to try my hand at digitizing because I didn't know how to do anything graphical yet.</p> <h1>Features</h1> <p>The keyboard.p8 library</p> <ul> <li> <p>handles backspace;</p> </li> <li> <p>does not accrue string unless polled;</p> </li> <li> <p>ergonomic prompt interaction code;</p> </li> <li> <p>echo can be on or off;</p> </li> <li> <p>allows you to substitute your own reader function;</p> </li> <li>return and 'p' will not pop up the pico-8 menu when being polled (unless enable_menu is set to true).</li> </ul> <h1>Acknowlegments</h1> <p>Many thanks to cabledragon for their inspiring <a href="https://www.lexaloffle.com/bbs/?tid=31079">mklib</a>, a mouse and keyboard library, project. Their keyboard code is only 62 tokens too.</p> https://www.lexaloffle.com/bbs/?tid=54769 https://www.lexaloffle.com/bbs/?tid=54769 Thu, 26 Oct 2023 11:14:37 UTC Emacs token count command <p>I've started to dip my toe into thinking about token minimization. Now I write most of my code in Emacs' <a href="https://github.com/Kaali/pico8-mode">pico8-mode</a>, which I love since it presents the code in the same font as pico-8 so I don't feel I've strayed too far. </p> <img style="margin-bottom:16px" border=0 src="/media/47628/4_pico8-mode.png" alt="" /> <p>But I've been aching for a way to count tokens outside of pico8's editor. I found the <a href="https://github.com/dansanderson/picotool">p8tool</a> which can do that and more, so I wrote this elisp function to make it accessible for me within Emacs. </p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>(defun pico8-token-count (beginning end) &quot;Calculate the number of pico-8 tokens in the file or region.&quot; (interactive &quot;r&quot;) (let ((path (if (use-region-p) (let ((temp-file (make-temp-file &quot;token-count-&quot; nil &quot;.p8&quot;))) (write-region &quot;pico-8 cartridge // http://www.pico-8.com\nversion 5\n__lua__\n&quot; nil temp-file) (write-region beginning end temp-file t) temp-file) (buffer-file-name)))) (message (shell-command-to-string (concat &quot;p8tool stats '&quot; path &quot;' | grep tokens | cut -d ' ' -f 3&quot;))))) </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Here it is in action.</p> <img style="margin-bottom:16px" border=0 src="/media/47628/pico8-token-count.gif" alt="" /> https://www.lexaloffle.com/bbs/?tid=54647 https://www.lexaloffle.com/bbs/?tid=54647 Wed, 18 Oct 2023 06:17:18 UTC Introducing tinytest <p> <table><tr><td> <a href="/bbs/?pid=134089#p"> <img src="/bbs/thumbs/pico8_tinytest-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=134089#p"> tinytest</a><br><br> by <a href="/bbs/?uid=47628"> shanecelis</a> <br><br><br> <a href="/bbs/?pid=134089#p"> [Click to Play]</a> </td></tr></table> <br /> This is the tinytest library for pico-8; it was inspired by the <a href="https://github.com/joewalnes/jstinytest">tinytest</a> javascript library by <a href="https://github.com/joewalnes">Joe Walnes</a>. It provides a basic unit test framework.</p> <p>You can use it one of two ways: as a no frills library or as a singing, dancing cart.</p> <h2>Library Usage</h2> <p>You will enjoy colored text reports but otherwise no frills, but it's very flexible this way.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>#include tinytest.p8 tinytest:new():run({ demo_pass = function(t) t:ok(true, &quot;hi&quot;) end, demo_fail = function(t) t:ok(false, &quot;bye&quot;) end, demo_error = function(t) assert(false, &quot;wtf&quot;) end, demo_misc = function(t) t:ok(false, &quot;bye2&quot;) assert(false, &quot;wtf2&quot;) end, })</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h2>Cart Usage</h2> <p>The cart comes with some images of bob from the incredibles in meme format and some audio sfx so you can hear the sweet sound of tests passing, failing, and erroring to make unit testing more fun.</p> <p>In your cart, define <code>my_tinytests</code>:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>-- yourcart.p8 my_tinytests = { demo_pass = function(t) t:ok(true, &quot;yep&quot;) end }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Edit tinytest.p8's cart:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>-- tinytest.p8 #include yourcart.p8</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Load tinytest.p8 and on every run it will exercise your tests. Since it does an include, you don't have to reload either.</p> <h1>TODO</h1> <ul> <li>Add more bob meme images (only two currently)</li> </ul> <h1>License</h1> <p>Copyright (c) 2023 <a href="https://mastodon.gamedev.place/%40shanecelis">Shane Celis</a><br /> Licensed under the <a href="https://opensource.org/licenses/MIT">MIT License</a></p> https://www.lexaloffle.com/bbs/?tid=54046 https://www.lexaloffle.com/bbs/?tid=54046 Sat, 09 Sep 2023 12:00:40 UTC cardboard_toad <p> <table><tr><td> <a href="/bbs/?pid=126445#p"> <img src="/bbs/thumbs/pico8_cardboard_toad-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=126445#p"> cardboard_toad</a><br><br> by <a href="/bbs/?uid=47628"> shanecelis</a> <br><br><br> <a href="/bbs/?pid=126445#p"> [Click to Play]</a> </td></tr></table> </p> <p>My six year old and I made this game for her upcoming birthday. She was inspired by paper mario and the idea of a pinata that ran away.</p> https://www.lexaloffle.com/bbs/?tid=51801 https://www.lexaloffle.com/bbs/?tid=51801 Tue, 28 Feb 2023 22:59:56 UTC