sparr [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=42027 Milliseconds? <p>stat(90) and neighbors give us wall clock time, which is useful for logging. However, at more than 1fps we'll get the same wall clock time on consecutive ticks/frames. It would be nice to be able to get milliseconds as well to disambiguate high frequency logs, without needing to track a frame counter in my game code.</p> https://www.lexaloffle.com/bbs/?tid=52427 https://www.lexaloffle.com/bbs/?tid=52427 Sun, 16 Apr 2023 15:08:09 UTC 0.1.12d built-in fill pattern demo <p> <table><tr><td> <a href="/bbs/?pid=73223#p"> <img src="/bbs/thumbs/pico8_fill_pattern_demo-5.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=73223#p"> fill_pattern_demo</a><br><br> by <a href="/bbs/?uid=42027"> sparr</a> <br><br><br> <a href="/bbs/?pid=73223#p"> [Click to Play]</a> </td></tr></table> </p> <p>Demonstrating the built-in fill patterns in 0.1.12d, which are implemented as numeric constants in variables whose names are the glyph characters.</p> https://www.lexaloffle.com/bbs/?tid=36861 https://www.lexaloffle.com/bbs/?tid=36861 Wed, 19 Feb 2020 08:50:36 UTC Gunner's Mates <p> <table><tr><td> <a href="/bbs/?pid=73142#p"> <img src="/bbs/thumbs/pico8_gunnersmates-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=73142#p"> gunnersmates</a><br><br> by <a href="/bbs/?uid=42027"> sparr</a> <br><br><br> <a href="/bbs/?pid=73142#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is a rough draft of my idea for <a href="https://itch.io/jam/weekly-game-jam-136">https://itch.io/jam/weekly-game-jam-136</a> &quot;Single Player Co-Op&quot;. You are a turret gunner that can only shoot in one direction, and you only have about 16 seconds (no visible timer yet) to shoot all the targets circling around. Unfortunately that's not enough time. So then you start over, pointing a different direction, helping out your previous iteration, but that's still not enough. So you do it a third time, and now there are three of you. Eventually there are enough of you working together to kill all the enemies within the time limit... and nothing happens because I didn't include an ending yet.</p> https://www.lexaloffle.com/bbs/?tid=36845 https://www.lexaloffle.com/bbs/?tid=36845 Sun, 16 Feb 2020 00:12:07 UTC Bubble Wrap tweetcart <p> <table><tr><td> <a href="/bbs/?pid=73119#p"> <img src="/bbs/thumbs/pico8_tweetbubblewrap-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=73119#p"> tweetbubblewrap</a><br><br> by <a href="/bbs/?uid=42027"> sparr</a> <br><br><br> <a href="/bbs/?pid=73119#p"> [Click to Play]</a> </td></tr></table> </p> <p>My first tweetcart with sound. Pop all the bubble wrap, then start again!</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>poke(24365,1)s=stat::r::b={}::m:: flip()cls()for p=0,63 do(b[p]and circ or circfill)(p%8*16+8,flr(p/8)*16+8,7,p%15+1)end if(s(34)&gt;0 and not b[p])sfx(0)b[p]=1 if(#b&gt;62)goto r x=s(32)y=s(33)pset(x,y,6)p=flr(y/16)*8+flr(x/16)goto m __sfx__ 000400000e6453667528655126350b624</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=36835 https://www.lexaloffle.com/bbs/?tid=36835 Sat, 15 Feb 2020 10:02:32 UTC Draw map from a string <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>------------------------------------------------------------------------ -- takes a string describing a map and the width of the map -- other parameters reimplement map() -- example &quot;0123456789abcdef&quot;,4 represents this 4x2 map: -- [[0x01,0x23,0x45,0x67],[0x89,0xab,0xcd,0xef]] function mapstring(mapstr, mapw, celx, cely, sx, sy, celw, celh, layer) -- remove[] to save tokens by making parameters mandatory ms, celx, cely, sx, sy, celw, celh, layer = ms or &quot;&quot;, celx or 0, cely or 0, sx or 0, sy or 0, celw or 1, celh or 1, layer or 0 for y=cely, cely+celh-1 do for x=celx, celx+celw-1 do local sprnum = tonum(&quot;0x&quot;..sub(mapstr,(y*mapw+x)*2+1,(y*mapw+x)*2+2)) if sprnum&gt;0 and band(layer, fget(sprnum))==layer then spr(sprnum, sx+(x-celx)*8, sy+(y-cely)*8) end end end 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>This might be useful for games that define a large number of small maps (like metroid or zelda screens).</p> https://www.lexaloffle.com/bbs/?tid=36818 https://www.lexaloffle.com/bbs/?tid=36818 Thu, 13 Feb 2020 11:31:28 UTC Terribly slow arc function, bonus asin() <p>This function uses bresenham's algorithm mirrored to the 8 octants, filtered by angle for the desired arc angles. It's so slow as to be useless; there are much better arc functions on the BBS already. I'm posting it for posterity and future reference, and because it inspired me to come up with a handy octant-range asin() approximation that might actually be useful</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>-- approximation of asin(d) for 0&lt;=d&lt;=.7071 -- exact at d==0, d==sin(1/16), d==sin(1/8) -- max error .0021 at d==sin(3/32) in given range -- error within that max beyond bounds up to d==sin(.137) function delta2angle(d) return d * 0x.29cf + (d &gt; 0x.61f8 and (d - 0x.61f8) * 0x.0785 or 0) end function arc(x, y, r, a1, a2, ...) a1 %= 1 a2 %= 1 if (a1 == a2) pset(x + r * cos(a1), y - r * sin(a1), ...) return a2 = a2 + (a1 &gt; a2 and 1 or 0) -- ensure a2&gt;a1 dx, dy = r, 0 while dy &lt;= dx do a = delta2angle(dy / r) for flip_x = -1, 1, 2 do for flip_y = -1, 1, 2 do for diag_mirror = 1, 2 do local ta = flip_x &lt; 0 and .5 - a or a ta = flip_y&lt;0 and -ta or ta ta = diag_mirror&gt;1 and (flr(ta * 4) + 1) / 4 - ta % 0.25 or ta ta = ta == .5 + flip_y * .25 and .5 - flip_y * .25 or ta % 1 if (ta + 1 - a1) % 1 &lt; a2 - a1 then local flips = {flip_x, flip_y} local d = {dx * flips[diag_mirror], dy * flips[3 - diag_mirror]} pset(x + d[diag_mirror], y + d[3 - diag_mirror], ...) end end end end dy += 1 if (dy * dy + dx * dx &gt; (r + .5) * (r + .5)) dx = dx - 1 end 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=36814 https://www.lexaloffle.com/bbs/?tid=36814 Wed, 12 Feb 2020 16:59:17 UTC rectfill and clip behave very differently with fractional parameters <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> x,y,w,h=64-10.75,64-10.25,20.5,20.5 rectfill(x,y,x+w-1,y+h-1,8) clip(x,y,w,h) rectfill(x,y,x+w-1,y+h-1,11) circ(64,64,12,12)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <img style="margin-bottom:16px" border=0 src="/media/42027/Screenshot from 2020-02-12 06-25-44.png" alt="" /> <p>Note that on the top and left the circle extends to the edge of the rect, as is expected since the rect was drawn to match the impending clip region. Note the extra row on the bottom, inside the original rectfill, outside the clipping rectangle.</p> <p>I think this is a bug. At the very least, it's a place where the documentation needs to be clarified.</p> <p>(the circle being off center is irrelevant)</p> https://www.lexaloffle.com/bbs/?tid=36811 https://www.lexaloffle.com/bbs/?tid=36811 Wed, 12 Feb 2020 14:04:24 UTC Markdown bug rendering code snippets <p>a snippet at the end of a line renders fine: <code>[this is code]</code></p> <p>however, a snippet in the middle of a line never terminates: <code>[this is code]</code> [this is not code] </p> https://www.lexaloffle.com/bbs/?tid=36762 https://www.lexaloffle.com/bbs/?tid=36762 Thu, 06 Feb 2020 19:57:59 UTC PicoChem, demake of SpaceChem, WIP <p> <table><tr><td> <a href="/bbs/?pid=72754#p"> <img src="/bbs/thumbs/pico8_picochem-6.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=72754#p"> picochem</a><br><br> by <a href="/bbs/?uid=42027"> sparr</a> <br><br><br> <a href="/bbs/?pid=72754#p"> [Click to Play]</a> </td></tr></table> </p> <p>Playable work in progress demake I've been working on, first for a week last January, now for a week again in the hopes of getting it playable for <a href="https://itch.io/jam/zachlike-jam">https://itch.io/jam/zachlike-jam</a></p> <p>The original game is <a href="http://www.zachtronics.com/spacechem/">http://www.zachtronics.com/spacechem/</a> and I highly recommend every game they have produced.</p> <p>Controls: arrows move the cursor. X to open a dialog to create/replace/delete instructions and arrows, arrows to move THAT cursor, X to confirm or O to cancel, optionally then arrows to set the direction/settings of the new instruction. O to open a dialog to run/pause/reset the simulation, or to grab and drop the sense and bond targets, or to change levels.</p> <p>What works here:<br /> arrows<br /> start (1)<br /> in (&alpha;/&beta;)<br /> out (&psi;/&omega;)<br /> grab/drop (magnet icon, minus one of the tips for just-grab and just-drop)<br /> rotate (curvy arrow icons)<br /> sync (pause icon)<br /> bond and unbond (&quot;O-O&quot; and &quot;O O&quot; icons)<br /> bond/unbond targets<br /> sense instruction (?) and targets<br /> flipflop (Y)<br /> output validity checking (99%)<br /> collision between atoms<br /> scoring and victory check</p> <p>What's implemented but not demonstrated here:<br /> full periodic table, all 113 elements with symbols and names and connection limits<br /> names and abbreviations for the molecules</p> <p>What's missing:<br /> title screen (might forego)<br /> menu screen (might forego)<br /> more levels/puzzles<br /> unlocking instructions based on progression<br /> the rest of the instruction types (fuse, split, swap)<br /> the rest of the target types (fusion, fission, quantum)<br /> saving<br /> score tracking</p> <p>I am seeking feedback on the iconography and interface in particular.</p> https://www.lexaloffle.com/bbs/?tid=36756 https://www.lexaloffle.com/bbs/?tid=36756 Wed, 05 Feb 2020 06:20:23 UTC Feature request: sample color in sprite editor fill mode <p>When drawing in the sprite editor, left click draws and right click picks up the color under the cursor (like the eye dropper in other image editing tools).<br /> When using the bucket fill tool, left click fills and right click... fills. It would be convenient and consistent if right click was still an eye dropper in this scenario.</p> https://www.lexaloffle.com/bbs/?tid=36717 https://www.lexaloffle.com/bbs/?tid=36717 Sun, 02 Feb 2020 02:58:46 UTC Feature request: tostr() honors metatable.__tostring() <p>It would be very handy if the built in tostr() was able to call the __tostring() metamethod for tables that have it defined. This is easy enough to add in our own code, but feels like it should be default behavior, similar to normal Lua.</p> https://www.lexaloffle.com/bbs/?tid=36701 https://www.lexaloffle.com/bbs/?tid=36701 Fri, 31 Jan 2020 23:21:23 UTC -32768/1 != -32768 <p>-32768 and 1 are both perfectly representable in the 16.16 fixed format, as 0x8000.0000 and 0x0001.0000. As far as I can see, this division should be perfect with no floating point shenanigans.</p> <p>However, <code>0x8000.0000/0x0001.0000==0x8000.0001</code></p> <p>which is throwing a wrench into some code I'm writing.</p> <p>Other nearby operations work fine, such as</p> <p><code>0x8000/2</code></p> <p>and</p> <p><code>0x7fff.ffff/1</code></p> <p>and</p> <p><code>0x8000.0001/1</code></p> <p>Then there's another group of operations that seem to be technically misbehaving but in a possibly desirable way.</p> <p><code>0x4000/0x0.8 0x2000/0x0.4 ... 0x1/0x0.0001</code></p> <p>should technically all overflow to 0x8000 (-32768) but they actually evaluate to 0x7fff.ffff which renders as 32768 because it's higher than 32767.9999. Maybe this is intentional, and maybe it's helpful, but I mention it here because it might also be related.</p> <p>PS: there are markdown rendering bugs affecting this post which is why it's weirdly formatted</p> https://www.lexaloffle.com/bbs/?tid=36692 https://www.lexaloffle.com/bbs/?tid=36692 Fri, 31 Jan 2020 01:28:34 UTC Feature Request: color() returns previous color <p>It would be helpful if calling color() to change the default color would return the previously default color. I am currently using a snippet like this to restore a previous default color:</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> t=band(peek(24357),15) color(c) blah blah color(t)</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=36629 https://www.lexaloffle.com/bbs/?tid=36629 Tue, 28 Jan 2020 06:39:43 UTC Paintball Logic <p> <table><tr><td> <a href="/bbs/?pid=72125#p"> <img src="/bbs/thumbs/pico8_paintball_logic-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=72125#p"> paintball_logic</a><br><br> by <a href="/bbs/?uid=42027"> sparr</a> <br><br><br> <a href="/bbs/?pid=72125#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is my first attempt at making a PICO 8 game. It is inspired by Zachtronics puzzle/programming games. The theme here is that a given series of balls will enter the grid from a queue, and you need to output the required series.</p> <p>This is the second version, which might actually qualify as a real puzzle game now, with a few different mechanics and half a dozen &quot;puzzles&quot;. I hope to continue development of features and more real puzzles!</p> https://www.lexaloffle.com/bbs/?tid=36565 https://www.lexaloffle.com/bbs/?tid=36565 Mon, 20 Jan 2020 06:21:17 UTC