Eniko [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=31258 Platformer sample, with slopes <p> <table><tr><td> <a href="/bbs/?pid=69543#p"> <img src="/bbs/thumbs/pico8_eniplatformsample-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=69543#p"> eniplatformsample</a><br><br> by <a href="/bbs/?uid=31258"> Eniko</a> <br><br><br> <a href="/bbs/?pid=69543#p"> [Click to Play]</a> </td></tr></table> </p> <p>Made a sample platformer, mostly to show how to do things like collisions, camera, jump buffering, and slopes. I wrote this to be clear rather than to save tokens, and it has no real gameplay to keep the core of the engine as clear as possible.</p> <p><a href="https://github.com/Enichan/Pico8Platformer">The code for this cart</a> can also be found on github and is MIT licensed.</p> <p><strong>Features:</strong></p> <ul> <li>Movement and jumping</li> <li>Collision checking and resolution</li> <li>Jump buffering</li> <li>Slopes</li> <li>Platforming camera</li> </ul> https://www.lexaloffle.com/bbs/?tid=35821 https://www.lexaloffle.com/bbs/?tid=35821 Fri, 01 Nov 2019 03:09:40 UTC Skewed pseudo 3D worldmap effect <p> <table><tr><td> <a href="/bbs/?pid=67391#p"> <img src="/bbs/thumbs/pico8_worldmapskew-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=67391#p"> worldmapskew</a><br><br> by <a href="/bbs/?uid=31258"> Eniko</a> <br><br><br> <a href="/bbs/?pid=67391#p"> [Click to Play]</a> </td></tr></table> </p> <p>Quick pseudo 3D worldmap skew effect meant to emulate something like Final Fantasy 6's overworld. The way this works is it copies the screen to the spritesheet after rendering the map, then goes through from top to bottom taking <strong>skewh</strong> rows and drawing them using <strong>sspr</strong>, adding 2 pixels more to the width every time. The <strong>skewh</strong> value defaults to 4.</p> <p>Left/down decreases <strong>skewh</strong> (minimum of 1), up/right increases <strong>skewh</strong> (maximum of 16), and the buttons toggle the skewing on and off.</p> https://www.lexaloffle.com/bbs/?tid=35292 https://www.lexaloffle.com/bbs/?tid=35292 Sun, 08 Sep 2019 05:32:05 UTC Depicofier - Converts PICO-8 syntax to standard Lua <p>Hi, I just released <a href="https://github.com/Enichan/Depicofier">Depicofier</a>, which converts PICO-8's syntax to regular Lua syntax. I looked at a couple existing solutions but they didn't work for me, so I made this. It's <a href="https://github.com/Enichan/Depicofier">open source</a> under the MIT license on Github.</p> <p>It should be feature complete, but if I missed anything please let me know.</p> <h1>Depicofier</h1> <p>Converts/translates PICO-8 style Lua syntax to standard clean Lua syntax. Download the <a href="https://github.com/Enichan/Depicofier/releases">latest release</a> here.</p> <p>This tool uses a <a href="https://github.com/antlr/grammars-v4/tree/master/lua">publicly available and well-tested Lua language grammar</a> to parse PICO-8 source code, so that any enhanced or special syntax or shorthand will only be converted where it should be.</p> <p>If you like this tool please consider kicking me a dollar <a href="https://www.patreon.com/sharkhugseniko">on Patreon</a>.</p> <h1>Usage</h1> <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>Depicofier.exe [inFile] [outFile] Or to output source to console: Depicofier.exe [inFile] -print Switches: -strict Print warnings for Lua syntax not found in Pico 8 such as binary operators, integer division, and bitwise shifts</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=34808 https://www.lexaloffle.com/bbs/?tid=34808 Mon, 22 Jul 2019 03:14:11 UTC Try catch finally exception/error handling <p>I know pcall isn't part of pico 8, which means you can't do regular Lua exception handling. I noticed though that coroutines swallow errors, and can return the error message. So I leveraged that to create a C#/Java style try catch finally function.</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 try(t,c,f) local co=cocreate(t) local s,m=true while s and costatus(co)!=&quot;dead&quot; do s,m=coresume(co) if not s then c(m) end end if f then f() end end cls() try(function() print(&quot;hi &quot;) --print(&quot;hi &quot; .. nil) end, function(e) print(&quot;an error occurred:\n&quot;..e) end, function() print(&quot;finally&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>To use just use it like above. The finally function is optional, so most people will probably use it like this:</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>try(function() -- code end, function(e) -- exception handler 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>Enjoy, and if you like it feel free to kick a buck to <a href="https://www.patreon.com/sharkhugseniko">my Patreon</a>.</p> https://www.lexaloffle.com/bbs/?tid=33091 https://www.lexaloffle.com/bbs/?tid=33091 Wed, 30 Jan 2019 20:24:33 UTC Bug with cstore in binary exports <p>I've created a two-cart application that uses two carts, and has two options:</p> <ol> <li>Use cstore to store data from the main cart into the 2nd cart, then finish the program</li> <li>Use reload to load data from the 2nd cart to the main cart</li> </ol> <p>When I bundle both carts using a binary export, the cstore function creates a file named the same as the filename I passed to the cstore function. E.g. I use &quot;cstore(0,0,4,&quot;exporttest_data.p8&quot;)&quot; and in AppData\Roaming\pico-8\cstore a file named that shows up, and it has the correct data in it. But when I restart the program and reload from the cart, it only shows the data of the cart as it was when it was bundled into a binary export.</p> <p>When I don't bundle the 2nd cart, a file called &quot;__(null).p8&quot; appears in the cstore folder, with the correct data, although the program still doesn't appear to be able to read it.</p> <p>Since there is a cstore folder and p8 carts are being created there I assume cstore is supposed to work in binary exports, but I'm pretty sure given the malformed &quot;__(null).p8&quot; file that there's a bug with it. I've added the main cartridge for testing.</p> <p> <table><tr><td> <a href="/bbs/?pid=60907#p"> <img src="/bbs/thumbs/pico8_nuhodupiku-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=60907#p"> nuhodupiku</a><br><br> by <a href="/bbs/?uid=31258"> Eniko</a> <br><br><br> <a href="/bbs/?pid=60907#p"> [Click to Play]</a> </td></tr></table> </p> <p>And here's the 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>cls() done=false while not done do if btn(4) then poke(0,8) poke(1,7) poke(2,6) poke(3,5) cstore(0,0,4,&quot;exporttest_data.p8&quot;) done=true elseif btn(5) then poke(0,0) poke(0,0) poke(0,0) poke(0,0) reload(0,0,4,&quot;exporttest_data.p8&quot;) print(peek(0)) print(peek(1)) print(peek(2)) print(peek(3)) done=true while btn() == 0 do flip() end end flip() end</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=32922 https://www.lexaloffle.com/bbs/?tid=32922 Wed, 16 Jan 2019 21:02:23 UTC Procgen space generator <p>Generates a random star system on load. Sometimes it generates one without a nebula at all so you may need to Cmd/Ctrl+R to reset if that happens.</p> <p> <table><tr><td> <a href="/bbs/?pid=55761#p"> <img src="/bbs/thumbs/pico55760.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=55761#p"> Procgen space generator</a><br><br> by <a href="/bbs/?uid=31258"> Eniko</a> <br><br><br> <a href="/bbs/?pid=55761#p"> [Click to Play]</a> </td></tr></table> </p> <p>My first Pico 8 cart on the BBS. This is a cart that generates a procgen starfield with nebulae, that you can scroll through (256x256 pixel size).</p> <p>The big technical achievement is the nebula. I used fractal noise with smoothing to generate the data, where every point is a 2x2 pixel area. After that I stored every row of colors as runs containing the byte length for that color and the color data. When drawing the screen I go through the runs of color, using memset to fill in the pixels which makes the dithering pretty easy, doing two rows of pixels on screen at the same time by flipping the pattern for odd numbered rows.</p> <p>The really tricky part was the scrolling, particularly in the X direction, because the patterns break if the camera X coordinate is odd and not even. To fix that I draw it as if it were 1 pixel to the left with the pattern flipped, then take the last 2x2 pixel area for a run, and copy the next run's right side pattern into the right side of the 2x2 area. That fixes the one pixel offset without too much of a performance penalty. I didn't fix artifacts along the edges of the screen and instead just lazy draw a black rectangle over it.</p> <p>I also used a monochrome hue ramp for this because it lets me do some other cool effects, like the blinking stars. The little one pixel stars also dim when they go behind the nebula, and dim more when behind the purple sections.</p> <p>Finally I wanted to add <a href="https://trasevol.dog/2017/02/01/doodle-insights-2-procedural-dithering-part-1/">random noise</a> like described in the linked article, but with scrolling I couldn't really forego cls(). What I wound up doing was trying to add a few random points every frame to a table, and only keeping the last 200, removing the oldest at the start of the table first, as well as removing any that are offscreen.</p> <p>All in all I'm really happy with how this turned out. :D</p> https://www.lexaloffle.com/bbs/?tid=31750 https://www.lexaloffle.com/bbs/?tid=31750 Mon, 27 Aug 2018 00:46:48 UTC