gcuellar [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=45484 Map size bigger than 128x32 <p>Here comes another newbie question:</p> <p>If I've got a map of 32*48 tiles (taller than wide), how should I handle the map data in order to print it directly with map() function?</p> <p>I saw that map can be extended to 64 tiles (height) if you use 0x1000 - 0x2000 memory, but I don't know how to tell the map function to use this extra space. </p> <p>Searching some post I've read that implementing some kind of map data streaming with peek and poke is a good a idea. Is there some resources, carts or tutorial that can helps me?</p> https://www.lexaloffle.com/bbs/?tid=41204 https://www.lexaloffle.com/bbs/?tid=41204 Tue, 19 Jan 2021 08:24:11 UTC Random select table item with relative probability <p>I'm struggling with a function that randomly picks up an element from a table with ponderated probability. For now this is my current code:</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>items = { {value=&quot;a&quot;,probability=.35}, {value=&quot;b&quot;,probability=.35}, {value=&quot;c&quot;,probability=.145}, {value=&quot;d&quot;,probability=.145}, {value=&quot;e&quot;,probability=.008}, {value=&quot;f&quot;,probability=.002} } -- total probability = 1 function rnd_item() local rnd_number = rnd() -- between [0,0.99999) local i = 1 local sum = items[i].probability while sum &lt; rnd_number do i += 1 sum += items[i].probability end return items[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>What is the problem with the implementation? Right, In some cases it crashes because 'i' goes out of bounds. It seems that the problem occurs when rnd_number is near 1 (i.e. 0.99997) but I can't figure out how I fix it.</p> <p>Is there a better implementation to solve the problem?</p> https://www.lexaloffle.com/bbs/?tid=40553 https://www.lexaloffle.com/bbs/?tid=40553 Wed, 25 Nov 2020 17:51:22 UTC Issue with rnd() and tostr() <p>Hi mates,</p> <p>I'm having some issues with an unexpected (for me) behaviour of rnd() and tostr() functions.</p> <p>Why this fragment of code prints value 1 if it's supposed that calling rnd() with no arguments produces values from 0 to 0.99999? Does tostr() perform some kind of ceil()?</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>local rnd_number = rnd() printh(&quot;rnd_number:&quot;..tostr(rnd_number),&quot;maplog.txt&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>Output:</p> <p>rnd_number:0.3293<br /> rnd_number:0.7758<br /> rnd_number:0.5745<br /> rnd_number:0.3691<br /> rnd_number:1<br /> rnd_number:0.0995<br /> rnd_number:0.1682</p> <p>I need to avoid that '1' value.</p> https://www.lexaloffle.com/bbs/?tid=40552 https://www.lexaloffle.com/bbs/?tid=40552 Wed, 25 Nov 2020 12:07:41 UTC 8x8 simple animator <p> <table><tr><td> <a href="/bbs/?pid=83384#p"> <img src="/bbs/thumbs/pico8_animator8x8v03-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=83384#p"> animator8x8v03</a><br><br> by <a href="/bbs/?uid=45484"> gcuellar</a> <br><br><br> <a href="/bbs/?pid=83384#p"> [Click to Play]</a> </td></tr></table> </p> <p>Hi folks!</p> <p>Last month I was trying out some Pico-8 features and finally brought them all together in my first cart.</p> <p>It's a simple 8x8 pixels animation editor. It features:</p> <ul> <li>Pixel editor with &quot;Pencil&quot; and &quot;Fill color&quot; tools.</li> <li>Animations allow up to 12 frames.</li> <li>Add/remove frames to the current animation.</li> <li>Editable frame delay.</li> <li>Play/pause animation controls.</li> <li>Keyboard device for text input.</li> <li>Export to PNG (only sprites, not metadata).</li> </ul> <p>For now I have an alpha version because is not finished yet but I wanted to share with you some kind of build that allows me put my mind in another subject.</p> <p>I've planned to add new features like multiple animations, export metadata capabilities, and much more, but for now this is the v0.1 release.</p> <p>Cheers!</p> <hr /> <p>New 0.2 version including:</p> <ul> <li>Fill tool fixed</li> <li>Start/stop animation with toogle button</li> <li>Export frames to clipboard</li> </ul> <hr /> <p>New 0.3 version including:</p> <ul> <li>Rotate sprite clockwise and anti-clockwise tool</li> <li>Undo tool with 12 actions memory per frame</li> </ul> https://www.lexaloffle.com/bbs/?tid=40055 https://www.lexaloffle.com/bbs/?tid=40055 Mon, 26 Oct 2020 22:46:32 UTC