YellowAfterlife [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=9596 ord &amp; chr (string&lt;-&gt;charcode) <p>Seems like a common request for functions to convert to and from char codes.<br /> Time will show whether it shall be added to the program, but until then you can do it by yourself:</p> <p>Initialization (59 tokens, 197 bytes):</p> <div> <div style="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> chars=&quot; !\&quot;#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~&quot; -- ' s2c={} c2s={} for i=1,95 do c=i+31 s=sub(chars,i,i) c2s[c]=s s2c[s]=c 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>(the blank comment is there solely to keep the editor from glitching out due to lack of escape sequence support)<br /> After this is executed, you'll find yourself with having two tables - s2c, holding char-&gt;code pairs, and c2s, holding code-&gt;char pairs.<br /> Since using these directly can be slightly less comfortable, here are a couple helper functions:</p> <p>chr(code) : Returns the char (string) for the given code [13tk\36b]:</p> <div> <div style="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 chr(i) return c2s[i] 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>Example: chr(33) == &quot;!&quot;</p> <p>ord(string, pos) : Returns the code for the character at the given position (optional argument) in a string [26tk\57b]:</p> <div> <div style="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 ord(s,i) return s2c[sub(s,i or 1,i or 1)] 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>Example: ord(&quot;Hello!&quot;, 6) == 33</p> <p>chrs(...codes) : Forms a string from one or more codes [50tk\103b]</p> <div> <div style="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 chrs(...) local t={...} local r=&quot;&quot; for i=1,#t do r=r..c2s[t[i]] end return r 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>Example: chrs(104,105,33) == &quot;hi!&quot;</p> <p>Additional notes:</p> <ol> <li>If you are in a dire need, you can shorten the chars-string to only include the uppercase letters.</li> <li>Depending on situation, you may also want this to handle linebreak via</li> </ol> <div> <div style="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> s2c[&quot;\n&quot;]=10 c2s[10]=&quot;\n&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>Then you can use the multiline string format [[ text ]]... which currently isn't considered as a string for token count though.</p> <p>Have fun!</p> https://www.lexaloffle.com/bbs/?tid=2420 https://www.lexaloffle.com/bbs/?tid=2420 Sat, 05 Sep 2015 14:26:07 UTC &quot;Light up&quot; pixels in area <p> <table><tr><td> <a href="/bbs/?pid=12469#p"> <img src="/bbs/thumbs/pico12468.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=12469#p"> &quot;Light up&quot; pixels in area</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=12469#p"> [Click to Play]</a> </td></tr></table> <br /> Can be combined with global palette to create objects that can only be seen in close promixity.<br /> Somewhat bearable performance-wise.<br /> Haxe source: <a href="https://gist.github.com/anonymous/c885964ca61431a8e90a"><a href="https://gist.github.com/anonymous/c885964ca61431a8e90a">https://gist.github.com/anonymous/c885964ca61431a8e90a</a></a></p> https://www.lexaloffle.com/bbs/?tid=2251 https://www.lexaloffle.com/bbs/?tid=2251 Sat, 08 Aug 2015 09:18:39 UTC hxpico8: Write PICO-8 games... in Haxe! <p>Blog post: <a href="http://yal.cc/introducing-hxpico8/"><a href="http://yal.cc/introducing-hxpico8/">http://yal.cc/introducing-hxpico8/</a></a><br /> Repository: <a href="https://github.com/YellowAfterlife/hxpico8"><a href="https://github.com/YellowAfterlife/hxpico8">https://github.com/YellowAfterlife/hxpico8</a></a><br /> Examples: <a href="https://github.com/YellowAfterlife/hxpico8xm"><a href="https://github.com/YellowAfterlife/hxpico8xm">https://github.com/YellowAfterlife/hxpico8xm</a></a></p> <p>In short, this project permits to use <a href="http://haxe.org/">Haxe</a> programming language to create programs for PICO-8 (by transpiling Haxe into PICO-8's flavour of Lua).<br /> This grants you classes, compile-time optimizations, constant and function inlining, and a whole bunch of other &quot;syntactic sugar&quot; features while keeping the output size reasonably small.<br /> For example, <a href="https://github.com/YellowAfterlife/hxpico8xm/blob/master/03_Input/Input.hx">this class</a> compiles to <a href="https://github.com/YellowAfterlife/hxpico8xm/blob/master/03_Input/Input.p8">this .p8</a>.<br /> Obviously, you can do <a href="https://www.lexaloffle.com/bbs/?tid=2220">more complex things</a> with it too.</p> <p>Have fun :)</p> https://www.lexaloffle.com/bbs/?tid=2221 https://www.lexaloffle.com/bbs/?tid=2221 Tue, 04 Aug 2015 04:09:08 UTC Isometric demo <p> <table><tr><td> <a href="/bbs/?pid=12244#p"> <img src="/bbs/thumbs/pico12242.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=12244#p"> Isometric demo Aug 04, 2015</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=12244#p"> [Click to Play]</a> </td></tr></table> <br /> This is a small demo that I've been showing on <a href="https://twitter.com/YellowAfterlife">Twitter</a>/<a href="http://yellowafterlife.tumblr.com/">Tumblr</a> yesterday. Currently there isn't much going on other than concept demonstration (and most of &quot;engine&quot; code needed). The code is laid out to allow taking it in various directions from here.<br /> <a href="https://github.com/YellowAfterlife/hxpico8xm/tree/master/Isometric">Source code</a></p> https://www.lexaloffle.com/bbs/?tid=2220 https://www.lexaloffle.com/bbs/?tid=2220 Tue, 04 Aug 2015 04:07:49 UTC Triangle drawing <p>Seeing screenshots of 3d[-ish] games here and there, a question arises - how does one draw filled triangles, and does so efficiently? I have tried porting one-before-last-step algorithm from here:<br /> <a href="http://forum.devmaster.net/t/advanced-rasterization/6145"><a href="http://forum.devmaster.net/t/advanced-rasterization/6145">http://forum.devmaster.net/t/advanced-rasterization/6145</a></a><br /> which resulted in this little monstrous function:<br /> <a href="https://gist.github.com/YellowAfterlife/34de710baa4422b22c3e"><a href="https://gist.github.com/YellowAfterlife/34de710baa4422b22c3e">https://gist.github.com/YellowAfterlife/34de710baa4422b22c3e</a></a><br /> but, alas, the math is just too much - it can barely draw half of screen worth of triangles before CPU use reaches 1.0. And that's before there's even any game<em>!</em><br /> I'd appreciate some pointers towards algorithms more suitable for pico-8. Or any help, really.</p> https://www.lexaloffle.com/bbs/?tid=2171 https://www.lexaloffle.com/bbs/?tid=2171 Mon, 27 Jul 2015 18:20:18 UTC printc - print() with color&amp;linebreak chars <p> <table><tr><td> <a href="/bbs/?pid=11746#p"> <img src="/bbs/thumbs/pico11747.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=11746#p"> printc</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=11746#p"> [Click to Play]</a> </td></tr></table> <br /> If you want to be able to change text color halfway through without splitting into multiple commands, here's just that at a price of 150 tokens / 265 compressed chars.<br /> So doing<br /> printc(&quot;hello ^8world^7!&quot;, 4, 4)<br /> will output</p> <img style="" border=0 src="http://i.imgur.com/KL2xwwL.png" alt="" /> <p>Could have been a bit smaller if there were functions to convert string to/from charcode.</p> https://www.lexaloffle.com/bbs/?tid=2148 https://www.lexaloffle.com/bbs/?tid=2148 Tue, 21 Jul 2015 18:40:07 UTC A quine. <p> <table><tr><td> <a href="/bbs/?pid=10854#p"> <img src="/bbs/thumbs/pico10855.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10854#p"> A fancy quine.</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=10854#p"> [Click to Play]</a> </td></tr></table> <br /> Update: Actually, why not go a bit further, and create a code viewer. Includes a custom font by me.</p> <p> <table><tr><td> <a href="/bbs/?pid=10854#p"> <img src="/bbs/thumbs/pico10853.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10854#p"> A quine. 1.0</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=10854#p"> [Click to Play]</a> </td></tr></table> <br /> A <a href="https://en.wikipedia.org/wiki/Quine_(computing)">quine</a> is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.</p> <p>This achieved by having the program modify it's own source and re-launch via the &quot;run&quot; command.<br /> Essentially it does this:</p> <div> <div style="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> print([[ (original program source here) ]]) </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=2012 https://www.lexaloffle.com/bbs/?tid=2012 Fri, 22 May 2015 04:27:21 UTC Command-line arguments? <p>It would make sense if dragging a .p8/.p8.png onto pico-8 (&quot;pico8 file_path&quot;) would cause it to cd to the containing directory, load the cart, and run it. In particular, this would allow to associate pico-8 with the .p8 format and/or start it from external applications (e.g. to use Notepad++/Sublime Text for editing code and have a key to launch pico-8 with the current file loaded).</p> https://www.lexaloffle.com/bbs/?tid=1928 https://www.lexaloffle.com/bbs/?tid=1928 Tue, 05 May 2015 03:03:30 UTC Stories at the dawn <p> <table><tr><td> <a href="/bbs/?pid=10439#p"> <img src="/bbs/thumbs/pico10437.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10439#p"> Stories at the dawn (May 03, 2015)</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=10439#p"> [Click to Play]</a> </td></tr></table> <br /> <strong>Stories at the dawn</strong> is a short minimalistic platformer game that I've made over the weekend.<br /> There is a [small] world to explore and multiple endings to uncover.</p> <p>The game is currently silent as I currently do not have enough experience to create anyhow worthy audio. If you feel like you can do something about that, feel free to message me or tinker with the game file (I have tried to add sufficient amounts of comments).</p> <p>If you liked the game, you can also support it via the <a href="http://yellowafterlife.itch.io/stories-at-the-dawn">itch.io page</a>.</p> https://www.lexaloffle.com/bbs/?tid=1919 https://www.lexaloffle.com/bbs/?tid=1919 Sun, 03 May 2015 14:18:18 UTC A 'cheat sheet'/API reference <p>Web: <a href="https://dl.dropboxusercontent.com/u/3594143/yal.cc/r/picodoc/index.html"><a href="https://dl.dropboxusercontent.com/u/3594143/yal.cc/r/picodoc/index.html">https://dl.dropboxusercontent.com/u/3594143/yal.cc/r/picodoc/index.html</a></a></p> <p>I've made a small cheat sheet/API reference thing for pico-8's standard functions.<br /> It provides a list of names+arguments, and you can click to expand/collapse sections/function descriptions:</p> <img style="" border=0 src="https://i.imgur.com/uao0Eda.png" alt="" /> <p>Generally intended to greatly reduce the amount of scrolling back and forth while looking things up.</p> https://www.lexaloffle.com/bbs/?tid=1906 https://www.lexaloffle.com/bbs/?tid=1906 Thu, 30 Apr 2015 16:03:11 UTC Picotris (Apr 29, 2015) <p> <table><tr><td> <a href="/bbs/?pid=10311#p"> <img src="/bbs/thumbs/pico10310.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10311#p"> Picotris (Apr 29, 2015)</a><br><br> by <a href="/bbs/?uid=9596"> YellowAfterlife</a> <br><br><br> <a href="/bbs/?pid=10311#p"> [Click to Play]</a> </td></tr></table> <br /> A pretty standard Tetris example.<br /> Scoring, colors, soft drops, wallkicks.<br /> Contains some comments on the process.<br /> No audio as I have not figured that out so far.</p> https://www.lexaloffle.com/bbs/?tid=1894 https://www.lexaloffle.com/bbs/?tid=1894 Wed, 29 Apr 2015 10:27:12 UTC