Txori [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=11790 Swap Sprites without breaking the Map <p>Hello everyone. Today I wrote a script to swap Sprites positions without messing with the Map. Very handy to reorganise your sprite sheet. And Flags will follow. Here's how it works:</p> <p><strong>1- Make a backup</strong></p> <p>First thing first: make a backup of your p8 file!<br /> This is important, as you can screw things up real quick if you do not pay attention.</p> <p><strong>2- Get the script</strong></p> <p>Create an empty file named &quot;swapspr.lua&quot; that you'll put alongside your p8 file.<br /> Copy/paste this script to &quot;swapspr.lua&quot; and save it:</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>function swapspr(n1,n2) for i=0,7 do local p1=i*64+n1*4+448*flr(n1/16) local p2=i*64+n2*4+448*flr(n2/16) local b1,b2=peek4(p1),peek4(p2) poke4(p2,b1) poke4(p1,b2) end local f1,f2=fget(n1),fget(n2) fset(n1,f2) fset(n2,f1) for x=0,127 do for y=0,127 do if mget(x,y)==n1 then mset(x,y,n2) elseif mget(x,y)==n2 then mset(x,y,n1) end end end cstore(0x0000,0x0000,0x7fff) 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>Note: the last 21 caracters &quot;-&quot; are important, otherwise, you'll mess the include.<br /> See bug here: <a href="https://www.lexaloffle.com/bbs/?pid=64985#p">https://www.lexaloffle.com/bbs/?pid=64985#p</a> (for <a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a>)</p> <p><strong>3- Prepare your p8 file</strong></p> <p>Open your p8 file and add those two line at the very begining of your 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 swapspr.lua swapspr(3,6)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>In this example, we are swaping positions of sprites numbers 3 and 6:</p> <p><a href="https://www.lexaloffle.com/bbs/files/11790/spr1.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/spr1.png" width=160 height=160 alt="" /></a> <a href="https://www.lexaloffle.com/bbs/files/11790/spr2.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/spr2.png" width=160 height=160 alt="" /></a></p> <p><strong>4- Run</strong></p> <p>Run your p8 file and that's it!<br /> Your sprites position have swaped while keeping their flags:</p> <p><a href="https://www.lexaloffle.com/bbs/files/11790/switch1.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/switch1.png" width=160 height=160 alt="" /></a> <a href="https://www.lexaloffle.com/bbs/files/11790/switch2.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/switch2.png" width=160 height=160 alt="" /></a></p> <p>And (magic) the Map didn't change:</p> <p><a href="https://www.lexaloffle.com/bbs/files/11790/map1.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/map1.png" width=160 height=160 alt="" /></a> <a href="https://www.lexaloffle.com/bbs/files/11790/map2.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/map2.png" width=160 height=160 alt="" /></a></p> <p><strong>5- Clean</strong></p> <p>Run this script as long as you need to swap positions.<br /> Don't forget to remove the two lines you added at the start of your code once you have finished. </p> <p>I hope this will save a lot of time for the Pico-Eighters like me that don't think about sprite order until the need to save space and tokens...</p> <p>Right now, it only swaps 8x8 sprites, but that can be modified easily.</p> https://www.lexaloffle.com/bbs/?tid=34438 https://www.lexaloffle.com/bbs/?tid=34438 Tue, 04 Jun 2019 16:35:35 UTC Draw SVG <p> <table><tr><td> <a href="/bbs/?pid=45150#p"> <img src="/bbs/thumbs/pico8_wozupuruze-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=45150#p"> Draw SVG 1.1</a><br><br> by <a href="/bbs/?uid=11790"> Txori</a> <br><br><br> <a href="/bbs/?pid=45150#p"> [Click to Play]</a> </td></tr></table> </p> <p><strong>Draw SVG</strong></p> <p>This is a tool do display vectorial drawings in PICO-8. It's useful for logos and big curved shapes that can't fit in memory as regular sprites. Also, you can zoom on those drawings at will.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/11790/mushroom_zoomcenter.gif" width=384 height=384 alt="" /> <p><span style="text-decoration: underline;"><strong>CONTROLS:</strong></span></p> <p>Arrows: move around<br /> Z/X: zoom in/out</p> <p><span style="text-decoration: underline;"><strong>HOW TO CONVERT SVG FILES TO PICO-8:</strong></span></p> <p>Simply use converter tool at:<br /> <a href="http://www.txori.com/index.php?static14/pico8">http://www.txori.com/index.php?static14/pico8</a><br /> The first number of each vector is the color of that vector.</p> <p><span style="text-decoration: underline;"><strong>RELEASE HISTORY:</strong></span></p> <p><div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"></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> v1.1 SVG draw engine entirely rewritten 30fps! v1.0 Initial release </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p></div></div></div></p> <p>-<br /> Find more stuff at <a href="www.txori.com">www.txori.com</a></p> https://www.lexaloffle.com/bbs/?tid=30064 https://www.lexaloffle.com/bbs/?tid=30064 Thu, 12 Oct 2017 18:16:14 UTC