ShootingStar [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=34534 Secret Palette Discovered <p>While playing around with poke/peek, I discovered theres a new palette to choose from.</p> <p>Poking the address 0x5f11 and setting it to a value of 0xf1 [<em>the 1 being the color in the palette, in this case dark blue]</em> you'll notice something strange. The blue seems to be even darker! this goes from 0xf0 to 0xff and corresponds to the color palette available naturally. It seems to darken/add a warm filter to the colors, allowing us to provide sprites with more specific details. You can see this in action via Neil Popham's post on twitter. To return the color to normal, replace the f before the color ID with 0. for example, 0x01 would be normal dark blue where as 0xf1 is the darker dark blue.<br /> <a href="https://twitter.com/ntpopham/status/1169166881607077888">https://twitter.com/ntpopham/status/1169166881607077888</a></p> <p>Address range is 0x5f10 to 0x5f1f from what I can tell, and there is no other hidden colors yet discovered but knowing zep... there probably is. :)</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/gb_0.gif" alt="" /> <p>Have fun with this discovery.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/EDj8u0NWwAMXptW.jpg" alt="" /> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/EDj8u0HWkAA7OIL.jpg" alt="" /> https://www.lexaloffle.com/bbs/?tid=35256 https://www.lexaloffle.com/bbs/?tid=35256 Wed, 04 Sep 2019 11:53:22 UTC PTCX Particle Engine <p>After some time of figuring everything out (including what I want to do in the future regarding the path of my life), I finally finished another snippet. This lets you efficiently create particles, as seen in this gif here:</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/sample_1.gif" alt="" /> <ul> <li> <p>Aprox. 480 Tokens</p> <h3>DOWNLOADS</h3> </li> <li><a href="https://drive.google.com/open?id=1RYEPbrNDUxr_G7karIqz7IEHRTCbFnnh">ptc_x.lua</a></li> <li><a href="https://drive.google.com/open?id=1xykU5sVQfUTGxXDkIJ1YHiErqKUUMT4U">ptc_x_c (compressed)</a></li> </ul> <p>DOCUMENTATION:</p> <h3><strong>IMPORTING</strong></h3> <p>Assuming you've placed the downloaded file into a folder called src, import with</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 src/ptc_x.lua</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 compressed version doesn't have an extension, so just use <strong>src/ptc_x_c</strong> without .lua</p> <hr /> <h3><strong>CREATE A GROUP</strong></h3> <p>You can create a particle group like so. </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>g_smp=_pgrp(64,64)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>now, g_smp will become a particle group and will be positioned at 64/64 (center of screen with unmodded camera). </p> <p><strong>GROUP TABLE VALUES</strong></p> <ul> <li>x/y <ul> <li>X and Y location of the group</li> </ul></li> <li>_ary <ul> <li>table that contains the particles</li> </ul></li> <li>_tk <ul> <li>Tick value. Increases by 1 per .tick() call.</li> </ul></li> <li>max <ul> <li>Allows you to limit how many particles the group can create/have.</li> </ul></li> <li> <p>linkcam</p> <ul> <li>Links a camera to the particle group.</li> </ul> <hr /> <h3><strong>CAMERA LINK</strong></h3> </li> </ul> <p>To link a camera, you'll need to use the collowing code in _init(). This code will set the groups camera to your own camera. This is needed because the particles will delete themselves when off camera.</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>g_smp.linkcam=cam</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 assumes your cam has x and y values.<br /> <code>cam={x=0,y=0}</code></p> <p>Alternatively, if you have a different setup, you can set the specifics for x/y...</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>g_smp.linkcam.x=cam_x g_smp.linkcam.y=cam_y</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <hr /> <h3><strong>PARTICLE TYPES</strong></h3> <p>Particle Types need to be functions that return an object. This is needed because of the possibility of randomization.</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> --create lava eruption fx1=function() return { --location x=rnd(8), y=-rnd(4), --initial velocity --and gaining velocity xv={ rnd(4)-rnd(4), rnd(0.01)-rnd(0.01) }, yv={ -3+rnd(1), 0.1 }, --colors (shifts through --array per tick) c={8,2,4,1}, --collision flag, nil for --no map collision. cflg=1, --life length l=200-rnd(30), --weight (for collision) --[x and y] --effects bounce rate w={1.4,3-rnd(1)}, -----optional parts here---- --setting size and size-gain --will make it a puff particle. s=0.5+rnd(2), sg=-rnd(0.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>Values:</p> <ul> <li>x/y <ul> <li>X and Y location of spawn (arranged by x/y of particle group)</li> </ul></li> <li>xv/yv <ul> <li>Xvelocity and Yvelocity of spawn. The first value is the initial velocity, and the second value is how much that value increases per frame. Setting the second value to 0.1 for the yv for example will cause the particles to continously increase their yvelocity. In the gif, notice how they start launching up then fall as if gravity is affecting them.</li> </ul></li> <li> <p>c</p> <ul> <li>Color array. Every tick of the particles lifespan will increment through the color array. Use only 1 value for a solid color, or make up your own patterns.</li> </ul> </li> <li> <p>cflg</p> <ul> <li>Collision Flag. This means that the particles will have physics if they come in contact with a sprite that has the set ID. Set to nil to skip collision checking, or just don't add this property to save yourself some tokens.</li> </ul> </li> <li> <p>l</p> <ul> <li>Life. This is how many frames the particles will stay alive for.</li> </ul> </li> <li>w <ul> <li>Weight. This is a Table and contains 2 values. One for calculating the division(slowdown) of the xvelocity and another for calculating the slowdown of the yvelocity. You only need this if you're using collision. This is also ignorable if you want to save tokens.</li> </ul></li> <li>s <ul> <li>Optional, sets the size of the particle. If its less than or equal to 1, it'll use pset instead of circfill. Otherwise, it becomes a &quot;puff particle&quot;, which is a type of particle that flips patterns (between 0b1010010110100101.1 and 0b0101101001011010.1) to create a simi-transparent circle creating the illusion of a blending effect. This is ignorable</li> </ul></li> <li> <p>sg</p> <ul> <li>Optional, sets the size-gain. The size of the particle will increase by this value per frame.</li> </ul> <hr /> <h3>Emitting particles</h3> </li> </ul> <p>To create particles, you'll need to use the emit function. For example:</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>g_smp.emit(fx1, 90)</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 first value is the particle group we've created earlier. The second value is how many particles it'll create per frame (or per call).</p> <hr /> <h3>DISPLAYING A GROUP</h3> <p>To actually get your particles to draw on screen, use the .tick command in _draw().</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>g_smp.tick()</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>That should be about it. If I missed anything, I'll add it later.</p> <hr /> <p>NON-DOWNLOAD VERSION</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>--[[DEPENDANCIES cdec.lua &bull;Col.Detection --]] --[[cdec.lua]] function cdec(mx, my, xl, yl, flg) local _=function(x,y,f) return fget(mget(x/8,y/8),f) end if _(mx+xl, my+yl, flg) or _(mx, my, flg) then return true end return false end --[[end of cdec.lua]] --[[main]] --particle patterns for puff particles ptc_pats={0b1010010110100101.1, 0b0101101001011010.1} --create a new particle grou[ function _pgrp(x,y) local a={ x=x, y=y, --particle array _ary={}, --tick, can be used for custom code _tk=0, --max particle limit max=500, linkcam={x=0,y=0} } a.emit=function(dt, rpt) for i=1,rpt do if #a._ary&lt;a.max then local _a=dt() _a.lc=0 _a.w=_a.w or {1,1} add(a._ary, _a) else return end end end a.tick=function() a._tk+=1 for i=1, #a._ary do local s=a._ary[i] if not s then goto e end local _={ s.x+a.x, s.y+a.y } ::r:: s.lc+=1 if s.lc&gt;=s.l or stat(1)&gt;0.9 then del(a._ary, a._ary[i]) if stat(1)&gt;0.9 then break end end s.x+=s.xv[1]+s.xv[2] s.y+=s.yv[1]+s.yv[2] s.xv[1]+=s.xv[2] s.yv[1]+=s.yv[2] if not s.cflg then goto d end if cdec(_[1], _[2], s.xv[1], s.yv[1], s.cflg) then if not cdec(_[1]+s.xv[1], _[2]-s.yv[1], s.xv[1], 0, s.cflg) then s.y-=(s.yv[1]*2) s.yv[1]=-s.yv[1] s.yv[1]/=s.w[2] s.xv[1]/=s.w[1] else s.x-=(s.xv[1]*2) s.xv[1]=-s.xv[1] s.xv[1]/=s.w[1] end end ::d:: local color=s.c[1+s.lc%#s.c] if _[1]-a.linkcam.x&gt;128 or _[1]-a.linkcam.x&lt;0 or _[2]-a.linkcam.y&gt;128 or _[2]-a.linkcam.y&lt;0 then s.lc=s.l goto e end if not s.s then fillp() goto px else s.s+=s.sg if s.s&lt;=1 then fillp() goto px end fillp(ptc_pats[1+(a._tk%#ptc_pats)]) goto cl end --set pixel ::px:: pset(_[1], _[2], color) goto e --set circle ::cl:: circfill(_[1], _[2], s.s, color) goto e ::e:: end fillp() end return a 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=35091 https://www.lexaloffle.com/bbs/?tid=35091 Sat, 17 Aug 2019 01:29:49 UTC SS_Tools -&gt; Dynamic Vegetation <p>This is an early version (not sure if I'll ever renew it), of a dynamic vegetation system I made that you can easily use thanks to #import.</p> <p>Basically, it automatically sets grass and/or flowers on top of a graphic with a specified flag turned on.<br /> <table><tr><td> <a href="/bbs/?pid=63789#p"> <img src="/bbs/thumbs/pico8_rahohazoya-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=63789#p"> rahohazoya</a><br><br> by <a href="/bbs/?uid=34534"> ShootingStar</a> <br><br><br> <a href="/bbs/?pid=63789#p"> [Click to Play]</a> </td></tr></table> </p> <p><em>INSTALL INSTRUCTIONS</em></p> <p>Navigate to your cart folder </p> <p>Windows: C:/Users/Yourname/AppData/Roaming/pico-8/carts<br /> OSX: /Users/Yourname/Library/Application Support/pico-8/carts<br /> Linux: ~/.lexaloffle/pico-8/carts</p> <p>Extract the folder from this download:<br /> <a href="https://drive.google.com/file/d/1Ac0nAAU2EaJB_MIr-UZ-WC0gzp5UW5KU/view?usp=sharing">https://drive.google.com/file/d/1Ac0nAAU2EaJB_MIr-UZ-WC0gzp5UW5KU/view?usp=sharing</a></p> <p>use this script in your cart:</p> <p><code>#include ss_scripts/ss_dynveg.p8</code></p> <p>Done.</p> <p>After exporting it'll use, like maybe about 500 tokens? couldn't get it less than that, least not with my current skills/dedication.</p> <p>CARTS SAMPLE 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 ss_scripts/ss_dynveg.p8 --ss_dynveg auto-creates a --camera you can use. --configure it to your --liking, but its best --to leave it default. --even if you dont use --camera(), its best to --at least include --_camera.x and _camera.y --in your viewport modification, --otherwise grass wont spawn --outside of the first 127x127 --pixels. --setup vegetation info grass_flag_id=0 --this flag needs --to be on in order to spawn grass --on the tile. grass_flow_spd=2 --how fast it --flows grass_veg_amount=4 --amount of --grass that spawns per tile, --max of 6. function _init() --spawn the grass and --set wave amp, increase --for larger waves. wave_amp=2 dgrass_init(wave_amp) end function _draw() cls(12) --draw entire map map() --draw the grass dgrass() --move camera, set it to --_camera.x and _camera.y, --which is the grasses --camera. note, this wont --overwrite another variable --named _camera. camera(_camera.x, _camera.y) --draw grass debug info grass_render_debug() end function _update() --move the grass camera --a bit. _camera.x+=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> https://www.lexaloffle.com/bbs/?tid=33983 https://www.lexaloffle.com/bbs/?tid=33983 Sun, 21 Apr 2019 23:47:13 UTC Emulating signed/unsigned char <p>While poking around with Pico8, I discovered a way to simulate <strong>char</strong> and <strong>unsigned char</strong> types.</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> -- tochar -- --[[ this function converts a value to make it emulate a char (256 max characters) it can emulate signed and unsigned chars. the value will not go beyond 0-255 if unsigned, and if signed the values will remain at -128 to 128. tochar returns a signed char and touchar returns an unsigned char. tochar(variable) touchar(variable) see sample; --]] function tochar(id) local res=id%256 return flr(res) end function touchar(id) local res=((id-128)%255)-127 return flr(res) end --sample number=1428 print(touchar(number, true))</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Theres the code snippit, put it in and play with the sample.</p> <p>info about it is in the code;<br /> enjoy for anybody wanting to make char variables for what ever your reasons might be.</p> https://www.lexaloffle.com/bbs/?tid=33846 https://www.lexaloffle.com/bbs/?tid=33846 Thu, 11 Apr 2019 19:03:08 UTC Super Efficient scene management <p>I have figured out a very effective and token-saving method of creating scenes.</p> <p>First, create a scene array called scnr(scene-running) and a variable called scn(for scene id). start it at 1</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>scnr={} scn=1</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>inside of that array we create functions with comments to tell which is what</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>--[[_init]]-- scnr={ --scene splash function() --some stuff here end, --scene title function() --some title stuff here 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>then inside _draw() we simply do:</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>--[[_draw]]-- scnr[scn]()</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Let me know if you guys know of another method thats more efficient.</p> https://www.lexaloffle.com/bbs/?tid=33688 https://www.lexaloffle.com/bbs/?tid=33688 Thu, 21 Mar 2019 21:18:29 UTC Smart save manager <p>This s a nifty, but small code snippit I made. Basically it takes the persistent cart data and forces it into your work-ram (starting from the range you specify in the sms_ram_start variable), so 256 values of your work ram will be used, but this is nice. You can save the specified ram storage to persistent data with the other function.</p> <p>★smsave() - saves memory to cart persistent data<br /> ★smload() - loads persistent data into work ram</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>--smart save manager --save work-ram to pers --and load pers to --work ram ★sms_ram_start=0x4300 function ★smsave() for i=0,255 do local _rs=★sms_ram_start+i if _rs&gt;0x5dff then break end poke(0x5e00+i, peek(_rs)) end end function ★smload() for i=0,255 do local _rs=★sms_ram_start+i poke(_rs, peek(0x5e00+i)) 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>Why would you need this? idk, but I was bored and this was fun to make for what ever reason.</p> https://www.lexaloffle.com/bbs/?tid=33679 https://www.lexaloffle.com/bbs/?tid=33679 Wed, 20 Mar 2019 21:16:11 UTC RPG Typewrite Text <p><strong>tokens: 823</strong><br /> This is a feature rich typewrite effect and its highly customizable. It features everything you need for RPG dialogue, including sprite-drawing mid line. Check it out for yourself with this demo here. (Press X to insta reveal or advance the dialogue).<br /> <table><tr><td> <a href="/bbs/?pid=62835#p"> <img src="/bbs/thumbs/pico8_hirikebg-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=62835#p"> hirikebg</a><br><br> by <a href="/bbs/?uid=34534"> ShootingStar</a> <br><br><br> <a href="/bbs/?pid=62835#p"> [Click to Play]</a> </td></tr></table> </p> <p><em>is this unoptimized?</em><br /> Well, probably yes. I'm still learning as I go, but I'm pretty proud of what I have so far so here it is. Enjoy, guys.</p> <p>The code for 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>--shooting★'s ultimate text --★ is used as my signature. --[[ text codes: $u1 = underline text (0 for no underline) $b## = border color, ##= a number, 0-15 $o## = outline color $c## = text color $d## = delay extra (0-99) if more delay is needed, use $f## and create a custom fx for it. $f## = special effects for any of these, you can use xx instead of a number to reset it to default (based on the default config you have set up) alternatively, you can use 16 to set it to nil and remove it. ]]-- --==configurations==-- --[[ configure your defaults here --]] ★msg_cnf = { --default color 1 15, --default highlight 2 nil, --default outline 3 1, --letter spacing 4 4, --new line spacing 5 7, --blip sound 6 0, --next msg sound 7 1, --------------------- --skip text/fast finish --button 8 5, --next action character '.', --next action character color 9 } --[[ standard variables,dont edit --]] ★msg_i=1 ★msg_t=0 ★msg_del=1 ★msg_cur=1 --==edit special fx here==-- --[[ special effects can be applied to all text after the fx code: $fid where id=a number starting with 1. in this sample, $f01 gives a wavy text effect. its auto-indexed, so make sure you comment similar to what i did to avoid confusion. self values: _dx (draw x) _dy (draw y) _fxv (fx value) _c (color) c (character) _b (border color, nil for none) _o (outline color, nil for none) _img (image index from sprite list) _upd (function, dont mod this) _id (index id of the character) --]] ★msg_fx = { --$f01 function(i, fxv) --floaty effect --[[ first, we get the self value (i) by using local self=★msg_str[i]. self._fxv = fx value self._dy = draw y, adds to the already rendering y position. --]] local self=★msg_str[i] self._dy=sin(self._fxv+fxv) self._fxv+=0.05 end, --$f02 function(i, fxv) --floaty effect 2 --[[ this time with random x locations. --]] local self=★msg_str[i] self._dy=sin(self._fxv+fxv) self._dx=rnd(4)-rnd(2) self._fxv+=0.05 end } --[[ store your messages here in this variable. make sure to comment the number to avoid confusion. empty text will end the text displaying. when you press the configured 'next' key, it auto-continues to the next string. --]] ★msg_ary={ --1 '$c09welcome$cxx to the text demo!', --2 'you can draw sprites\n$i01 like this, and you can\n\nadd a delay$d04...$dxxlike this!', --3 'looking for $d08$f01spooky$fxx$dxx effects?$d30\n$dxxhmm, how about some\n$oxx$o16$c01$b10highlighting$bxx', -- '$o16$u1underlining?$u0$d30$oxx $dxx geeze, you\'re\na $f02hard one to please!', --5 '' } --string storage-- ★msg_str={} --function to set message --id=index in ★msg_ary function msg_set(id) --sine variable ★msg_sin=0 ★msg_cur=id --reset message string ★msg_str={} --reset index counter ★msg_i=1 local __id=0 for i=1,#★msg_ary[id] do --add characters add(★msg_str, { --character c=sub(★msg_ary[id], i, i), --color _c=★msg_cnf[1], --bg color _b=★msg_cnf[2], --outline color _o=★msg_cnf[3], --draw_x and draw_y _dx=0, _dy=0, --fx value _fxv=0, --image to draw _img=nil, --extra delay _del=0, --update function for fx _upd=function() end, _id=__id }) __id+=1 end msgparse() end --parse entire message :u function msgparse() for i=1,#★msg_str do if not ★msg_str[i+1] then return end local t=★msg_str[i].c local c=★msg_str[i+1].c if t=='$' and (c=='c' or c=='b' or c=='f' or c=='d' or c=='o' or c=='i') then ★msg_str[i].skp=true ★msg_str[i+1].skp=true ★msg_str[i+2].skp=true ★msg_str[i+3].skp=true local val=tonum(★msg_str[i+2].c..★msg_str[i+3].c) for j=i,#★msg_str do if c=='c' then ★msg_str[j]._c=val or ★msg_cnf[1] end if c=='b' then ★msg_str[j]._b=val or nil end if c=='f' then ★msg_str[j]._upd=★msg_fx[val] or function() end end if c=='d' then ★msg_str[j]._del=val or 0 end if c=='o' then ★msg_str[j]._o=val or ★msg_cnf[3] end if c=='i' then ★msg_str[i+4]._img=val or nil end end end if t=='$' and c=='u' then ★msg_str[i].skp=true ★msg_str[i+1].skp=true ★msg_str[i+2].skp=true for j=i,#★msg_str do ★msg_str[j]._un=tonum(★msg_str[i+2].c) or 0 end end end end --function to draw msg function msg_draw(x, y) --return if text is empty if ★msg_ary[★msg_cur] == '' then return end --set a btnp value if not btn(★msg_cnf[8]) then ★msg_btnp=false end --loop... while ★msg_i&lt;#★msg_str do --idk why you're trying to --read this if btnp(★msg_cnf[8]) then ★msg_i=#★msg_str-1 ★msg_btnp=true end --like seriously, its just --vital function stuff. ★msg_t+=1 if ★msg_str[★msg_i].skp then ★msg_i+=1 end if ★msg_t&gt;=★msg_del+★msg_str[★msg_i]._del then ★msg_i+=1 sfx(0) ★msg_t=0 end break; end --i mean, hey... if you want --to keep reading, go ahead. local i=1 local _x=0 local _y=0 while i&lt;★msg_i do if not ★msg_str[i] then return end if not ★msg_str[i].skp then --i wont try and stop you. _x+=★msg_cnf[4] if ★msg_str[i]._b and ★msg_str[i]._b != 16 then rectfill(x+_x, y+_y-1, x+_x+★msg_cnf[4], y+_y+5, ★msg_str[i]._b) end if ★msg_str[i]._img then spr(★msg_str[i]._img, x+_x+★msg_str[i]._dx, y+★msg_str[i]._dy+_y) end --you're probably getting --bored now, right? if ★msg_str[i]._o and ★msg_str[i]._o != 16 then local __x=x+_x+★msg_str[i]._dx local __y=y+★msg_str[i]._dy+_y for i4=1,3 do for j4=1,3 do print(★msg_str[i].c, __x-2+i4, __y-2+j4, ★msg_str[i]._o) end end end --yep, not much here... print(★msg_str[i].c, x+_x+★msg_str[i]._dx, y+★msg_str[i]._dy+_y, ★msg_str[i]._c) if ★msg_str[i]._un == 1 then line(x+_x, y+_y+5, x+_x+★msg_cnf[4], y+_y+5) end if ★msg_str[i].c == '\n' then _x=0 _y+=★msg_cnf[5] end else --why am ☉ even trying --to get you to not read it? end i+=1 end if ★msg_i&gt;=#★msg_str then print(★msg_cnf[9], x+★msg_cnf[4]+_x+cos(★msg_sin), y+_y+sin(★msg_sin), ★msg_cnf[10]) ★msg_sin+=0.05 if btnp(★msg_cnf[8]) and ★msg_btnp != true then sfx(1) ★msg_cur+=1 msg_set(★msg_cur) end end --i mean, its not like --i care. for ii=1,#★msg_str do ★msg_str[ii]._upd(ii, ii/3) end --enjoy the script :)-- 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>How to use it is documented in the code as comments.</p> <p>Quick sample setup:</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>--sample function _init() msg_set(1) end function _draw() cls() msg_draw(4, 4) 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!</p> https://www.lexaloffle.com/bbs/?tid=33645 https://www.lexaloffle.com/bbs/?tid=33645 Fri, 15 Mar 2019 20:42:50 UTC PicoUI (wip) <p>So I've started working on a pico8 U.I today. I'll be re-installing linux (switching to fedora) soon so I'm not only using this post as a backup, but also using this post as a sort of preview of things to come.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/ssui_7.gif" alt="" /> <p>I wouldn't bother using this just yet, though. Its quite un-optimized so far and not yet finished, and its also not documented and the sample code used for the gif I generated was a bit sloppily thrown together, but if you want to take the code and tweak it to your own needs then by all means do so.<br /> running 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>--s★ui --shooting★ function s★ui_init() s★ui={frame={},mse={0,0}} --configure here --[1]=bg, [2]=border, --[3]=content color --[4] = scrollbar back color --[5] = scrollbar btn color --[6] = scrollbar btn hover -- color --[7] = content btn bg color --[8] = content btn border -- color --[9] = content btn fg color --[10]= content btn bg hover --[11]= content btn border -- hover --[12]= content btn text -- hover s★ui_wincol={ 6, --1 5, --2 1, --3 1, --4 6, --5 9, --6 2, --7 1, --8 6, --9 1, --10 8, --11 6 --12 } --mouse icon s★ui_msei = 1 --content padding s★ui_padding=2 --enable mouse poke(0x5f2d, 1) end --ui update function function s★ui_upd() --ui mouse coords s★ui.mse[1] = stat(32) s★ui.mse[2] = stat(33) for i=1,#s★ui.frame do --draw the frame s★ui.frame[i].draw() end --draw mouse sprite spr(s★ui_msei, s★ui.mse[1], s★ui.mse[2]) end --create a new frame function s★ui_new(d) d = d or {} --frame can have custom cols, --bg,border and content d.bg=d.bg or s★ui_wincol[1] d.bdr=d.bdr or s★ui_wincol[2] d.cnt=d.cnt or s★ui_wincol[3] d.elm={} d.cs=0 d.highest_cnt=0 --close button, left as object --might add more btns later~ d.btns={ { title='x', x=117, y=2 } } --if disabled close if d.dc == true then d.btns[1].disabled = true end --else, create close action d.btns[1].action=function() d.active=false end d.btns[1].draw=function() local col=5 if s★ui.mse[1] &gt; d.btns[1].x and s★ui.mse[1] &lt; d.btns[1].x + 8 and s★ui.mse[2] &gt; d.btns[1].y and s★ui.mse[2] &lt; d.btns[1].y + 8 and d.dc != true then col=1 if stat(34) == 1 then d.btns[1].action() end end print(d.btns[1].title, d.btns[1].x+3, d.btns[1].y, col) end d.active=true d.draw=function() if d.active == false then return end cls(d.bg) for i=1, #d.elm do d.elm[i].draw() end rect(2, 8, 125, 125, d.bdr) rectfill(0, 0, 127, 7, d.bg) rectfill(0, 126, 127, 127, d.bg) for i=1, #d.btns do d.btns[i].draw() end print(d.title, 2, 2, d.cnt) rectfill(116, 111, 124, 124, s★ui_wincol[4]) local mainsc=s★ui_wincol[5] local hovcol={mainsc,mainsc} if s★ui.mse[1] &gt; 116 and s★ui.mse[1]&lt;124 and s★ui.mse[2]&gt;112 and s★ui.mse[2]&lt;118 then hovcol[1] = s★ui_wincol[6] if stat(34) == 1 then d.cs-=3 d.cs=max(d.cs, 0) end end if s★ui.mse[1] &gt; 116 and s★ui.mse[1]&lt;124 and s★ui.mse[2]&gt;118 and s★ui.mse[2]&lt;124 then hovcol[2] = s★ui_wincol[6] if stat(34) == 1 then d.cs+=3 end end print('⬆️',117, 112, hovcol[1]) print('⬇️',117, 119, hovcol[2]) rectfill(3, 118, 116, 124, 1) print(':'..d.cs/3, 4, 119, 6) end add(s★ui.frame, d) return s★ui.frame[#s★ui.frame] end --new element function s★ui_newelem(f, d) d.type = d.type or 'text' d.clicked=0 d.draw=function() local cy=d.y+8+s★ui_padding-f.cs local cx=d.x+2+s★ui_padding if d.type == 'text' then print(d.txt, cx, cy, d.col or f.cnt) end if d.type == 'hr' then line(4, cy, 123, cy, d.col or f.cnt) end if d.type == 'btn' then local cols={s★ui_wincol[7], s★ui_wincol[8], s★ui_wincol[9]} if s★ui.mse[1] &gt;= cx and s★ui.mse[1] &lt;= cx+(#d.txt*4)+2 and s★ui.mse[2] &gt;= cy and s★ui.mse[2] &lt;= cy+8 then cols={s★ui_wincol[10], s★ui_wincol[11], s★ui_wincol[12]} if stat(34) == 1 then d.clicked+=1 if d.clicked==1 then d.act() end else d.clicked=0 end end d.clicked=stat(34) rectfill(cx, cy, cx+(#d.txt*4)+2, cy+8, cols[1]) rect(cx, cy, cx+(#d.txt*4)+2, cy+8, cols[2]) print(d.txt, cx+2, cy+2, cols[3]) end if d.type == 'chk' then d.checked = d.checked or false print(d.txt, cx+8, cy+1, d.col or f.cnt) if s★ui.mse[1] &gt;= cx and s★ui.mse[1] &lt;= cx+(#d.txt*4)+6 and s★ui.mse[2] &gt;= cy and s★ui.mse[2] &lt;= cy+6 then cols={s★ui_wincol[10], s★ui_wincol[11], s★ui_wincol[12]} if stat(34) == 1 then d.clicked+=1 if d.clicked==1 then d.checked = not d.checked end else d.clicked=0 end end d.clicked=stat(34) rect(cx, cy, cx+6, cy+6, d.col or f.cnt) if d.checked==true then line(cx+1, cy+3, cx+2, cy+6, d.col or f.cnt) line(cx+2, cy+6, cx+5, cy, d.col or f.cnt) end end end add(f.elm, d) return f.elm[#f.elm] 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>sample code used in gif above:</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 _init() s★ui_init() wnd_main = s★ui_new({ title='pico8-ui', dc=true }) --wnd_main content s★ui_newelem(wnd_main, { x=0, y=0, txt='welcome to the pico-8 ui\ndemo!\n\nlicense:\nthis doesn\'t actually have\none, but i thought it would\nlook kinda cool to have\nsome kind of massive text\nwall here for this demo,\nso here it is. please use the\nbuttons on the bottom right\nhand corner to scroll this\npage!'}) s★ui_newelem(wnd_main, { x=0, y=112, txt=[[oh, neat. you scrolled! now that you have scrolled, how about we get a little more into it? if you want to use this neat u.i, then be prepared because it takes 929 tokens. however, as you can tell its a fully functional u.i system with the ability to scroll content and create buttons, checkboxes and horizontal rules. here's a sample setup! function _init() s★ui_init() --setup main window wnd_main = s★ui_new({ title='pico8-ui', dc=true --disable close }) s★ui_newelem(wnd_main, { x=0, y=0, txt='this is some text' }) wnd_checkbox = s★ui_newelem( wnd_main, { type='chk', x=80, y=86, txt='checkbox' }) end ]]}) s★ui_newelem(wnd_main, { type='hr', x=0, y=13 }) --accept button s★ui_newelem(wnd_main, { type='btn', y=86, x=0, txt='i accept', act=function() sfx(0) if wnd_checkbox.checked == true then wnd_main.active=false end end }) --fix close button s★ui_newelem(wnd_main, { type='btn', y=96, x=0, txt='enable win close', act=function() sfx(1) wnd_main.dc = false end }) s★ui_newelem(wnd_main, { type='hr', x=0, y=106, col=13 }) wnd_checkbox = s★ui_newelem(wnd_main, { type='chk', x=80, y=86, txt='checkbox' }) --end end function _draw() cls() s★ui_upd() 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=33257 https://www.lexaloffle.com/bbs/?tid=33257 Wed, 13 Feb 2019 19:35:00 UTC water reflection effect <h3>154 tokens</h3> <p>Still being somewhat new to pico8, I managed to make this neat water reflect effect.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/ss_tools_8.gif" alt="" /> <p>I'm sure it can be optimized a great deal, but for now its the best I can come up with, though I'm always improving.</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>--s★_tool -&gt; rflc --[[ configuring to configure this tool, in your _init() or when ever you see a need to change the waters settings, you can use this code ◆ s★_rf_sy = 105 the sample code above sets the start-y position of the water. ◆ s★_rf_data = value data: ◆ sy - start y ◆ bg - background color ◆ ic - ignore color (for cls background colors so it doesn't draw a color that it doesn't need to. if you're using cls(1) then set ic to 1, for example.) ◆ rq - reflection quality ◆ wa - wave amp (how large it waves left/right) ◆ ws - wave speed (how fast it waves left/right) ]]-- --defaults s★_rf_sy=104 s★_rf_bg=1 s★_rf_ic=0 s★_rf_rq=13 s★_rf_wa=2 s★_rf_ws=0.02 --wave value, don't mod this --unless you need to. s★_rf_wv=0 --reflection effects s★_rflc = function(mode, data, val) --if not configuring, then draw rectfill(0, s★_rf_sy, 127, 127, s★_rf_bg) local _scl=(s★_rf_rq/127) local _ht=127-s★_rf_sy local _flc_col = 0 for i=0,s★_rf_rq do for j=0, _ht do local _x=((i/s★_rf_rq)*127)+(cos(s★_rf_wv+(j/6))*(s★_rf_wa+j/8)) local _s=(s★_rf_rq/128)*10 local c=pget(_x,s★_rf_sy-j) if c!= s★_rf_bg and c!= s★_rf_ic and c != 0 then local _y=(j/2) line(_x-_s-_y-j/14, 1+j+s★_rf_sy, _x+_s+_y+j/14, j+s★_rf_sy, c) end end end s★_rf_wv+=s★_rf_ws 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 this, just put this code in your draw code under everything you want to reflect.<code>s★_rflc()</code> </p> <p>compressed 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>s★_rf_sy=104 s★_rf_bg=1 s★_rf_ic=0 s★_rf_rq=13 s★_rf_wa=2 s★_rf_ws=0.02 s★_rf_wv=0 s★_rflc = function(mode, data, val) rectfill(0, s★_rf_sy, 127, 127, s★_rf_bg) local _scl=(s★_rf_rq/127) local _ht=127-s★_rf_sy local _flc_col = 0 for i=0,s★_rf_rq do for j=0, _ht do local _x=((i/s★_rf_rq)*127)+(cos(s★_rf_wv+(j/6))*(s★_rf_wa+j/8)) local _s=(s★_rf_rq/128)*10 local c=pget(_x,s★_rf_sy-j) if c!= s★_rf_bg and c!= s★_rf_ic and c != 0 then local _y=(j/2) line(_x-_s-_y-j/14, 1+j+s★_rf_sy, _x+_s+_y+j/14, j+s★_rf_sy, c) end end end s★_rf_wv+=s★_rf_ws 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=33237 https://www.lexaloffle.com/bbs/?tid=33237 Mon, 11 Feb 2019 14:03:59 UTC Simple Scene Manager <p><a href="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-02-02 21-23-19.png" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-02-02 21-23-19.png" width=160 height=88 alt="" /></a></p> <p>Hi, everyone. I made a very simplistic scene manager for you all to use, its somewhat compressed as well. here's an example:<br /> <table><tr><td> <a href="/bbs/?pid=61476#p"> <img src="/bbs/thumbs/pico8_scenemanager_sample-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=61476#p"> scenemanager_sample</a><br><br> by <a href="/bbs/?uid=34534"> ShootingStar</a> <br><br><br> <a href="/bbs/?pid=61476#p"> [Click to Play]</a> </td></tr></table> </p> <p>Basically, this scene manager allows you to create init, update and draw for each scene (as well as anything else you want to cook up, of course).</p> <p>HOW TO USE<br /> to make a new scene, use the command 'nscn' inside of your init function. for example: nscn({init=function() end, update=function() end, draw=function() end})</p> <p>to grab the current scene thats running so you can modify it or its variables, you can simply create a local variable called 'self'.</p> <p>local this=scn['self']()</p> <p>(or local this=scn.self())</p> <p>to switch to a scene, you'll need to comment the ID of that scene so you don't lose track. I recommend you have a function that launches at the init() of your game that creates all of your scenes for you.</p> <p>command to load a scene: scn_mng.go(id) where id is the scene number you want to run.</p> <p>Finally, you need to put the 2 commands inside draw() and update(). in update(), put scn_mng.update() and in draw put scn_mng.draw()</p> <p>code snippit:</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>--scene manager --shooting★ scn = {self=function() return scn[scn_mng.r] end} scn_mng = { go=function(s) scn_mng.r = s scn[s].init() end, draw=function() scn[scn_mng.r].draw() end, update=function() scn[scn_mng.r].update() end } function nscn(d) local a={ init=d.init or function() end, update=d.update or function() end, draw=d.draw or function() end } add(scn, a) 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>code example (used in cart above)</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>--sample function create_scenes() --scene 1 nscn({ init=function() --create a local var called --this and set it to self --scene local this=scn['self']() --create particles this.particles = {} for i=0,16 do local a={rnd(127),rnd(127),rnd(2)} add(this.particles, a) end --create a timer to switch --to scene 2 with this.timer=0 end, update=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer+=1 if this.timer==120 then this.timer=0 --switch to scene 2 scn_mng.go(2) end end, draw=function() --create a local var called --this and set it to self --scene local this=scn['self']() --draw particles for i=1,#this.particles do pset(this.particles[i][1], this.particles[i][2], 7) this.particles[i][1]+=this.particles[i][3] this.particles[i][2]+=this.particles[i][3] end end }) --scene 2 nscn({ init=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer=0 end, update=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer+=1 if this.timer==120 then this.timer=0 --switch back to scene 1 scn_mng.go(1) end end, draw=function() cls(1) end }) end function _init() --create scenes create_scenes() scn_mng.go(1) end function _update() scn_mng.update() end function _draw() cls() scn_mng.draw() print('running scene '..scn_mng.r, 0, 0, 7) 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=33134 https://www.lexaloffle.com/bbs/?tid=33134 Sun, 03 Feb 2019 02:34:55 UTC Super Debug Menu <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-30 22-33-26.png" alt="" /> <p>this nifty code lets you debug your project. Features it provides are in the codes guide on how to use it~</p> <p> <table><tr><td> <a href="/bbs/?pid=61379#p"> <img src="/bbs/thumbs/pico8_superdebug-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=61379#p"> superdebug</a><br><br> by <a href="/bbs/?uid=34534"> ShootingStar</a> <br><br><br> <a href="/bbs/?pid=61379#p"> [Click to Play]</a> </td></tr></table> </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>--super debug v 1.0 --shooting★ --[[ &hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip; how-to use &hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip; to use this code, check out tab 2 and copy the compressed code. once its coppied, you'll need to put &quot;sdbg()&quot; (without quotes) inside of your _draw() function, at the very bottom. make sure its drawn last. by default, the key to display debug info is the tilde key ( the ` next to the number 1 on standard u.s keyboards). you can change this by simply changing dbg_dbtn. at your init, you can put dbg_dbtn = 't' for example, and then 't' on your keyboard will open the debug info. if you want to adjust the memory location, you can adjust the variable called addr. by default, its 0x5e00. to edit it, do the same as editing dbg_dbtn, just put it in _init(). ( addr = 0x5e01 ) &hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip; ★features★ &hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip; this code displays the following information: ◆ framerate (top-right) &hellip;&hellip;&hellip; ◆ cpu usage &hellip;&hellip;&hellip; ◆ mem usage/max mem &hellip;&hellip;&hellip; ◆ test count (how many times you tested your project since installing this code) &hellip;&hellip;&hellip; ◆ mouse info (location, click #) &hellip;&hellip;&hellip; ◆ tile flags &amp; id (displays all 8 flags on the tile you're hovering over) &hellip;&hellip;&hellip; ◆ color of hovering-pixel (gets the color of the pixel you're currently hovering the mouse over.) &hellip;&hellip;&hellip; ◆pico version &hellip;&hellip;&hellip; ◆ uptime (how long the test has been running for) &hellip;&hellip;&hellip; ]] </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Alternatively, you can copy the compressed code directly and just follow instructions from the code displayed above. here's the compressed code that makes the entire thing run.</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>--code dbg_dbtn = '`' dbt = 7 don = false cc = 8 mc = 15 addr = 0x5e00 function dtxt(txt,x,y,c) print(txt, x,y+1,1) print(txt,x,y,c) end function init_dbg() poke(0x5f2d, 1) test_num = peek(&and;addr) or 0 poke(&and;addr, test_num+1) end dbtm = 0 dbu = {0,0,0} function sdbg() if stat(31) == dbg_dbtn then if don==false then don=true else don=false end end if don != true then return end local c=dbt local cpu=stat(1)*100 local mem=(stat(0)/100)/10*32 local fps=stat(7) local u=stat(7)..'' local _x=124-(#u*4) local du = {dbu[1],dbu[2],dbu[3]} dtxt(u, 124-(#u*4), 1, c) u=cpu..'%' dtxt(u, 124-(#u*4), 7, c) u=mem..'kb /' dtxt(u, 124-(#u*4)-32, 13, c) dtxt('31.25kib', 128-33, 13, c) dtxt(du[3]..'h', 124-44, 128-9, c) dtxt(du[2]..'m', 124-28, 128-9, c) dtxt(du[1] ..'s', 124-12, 128-9, c) dtxt('cpu', 1, 7, c) dtxt('mem', 1, 13, c) dtxt('pico-'..stat(5), 1, 128-15, c) dtxt('uptime', 1, 128-9, c) dbtm+=1 dbu[1] = flr(dbtm/stat(8)) dbu[2] = flr(dbu[1]/60) dbu[3] = flr(dbu[2]/60) dtxt('test number: '..peek(0x5e00), 0, 24, c) dtxt('mouse: {'..stat(32)..','..stat(33)..'}\nbitmask: '..stat(34), 0, 30, c) draw_dbg_info(c) end function draw_dbg_info(c) local m = {stat(32)/8, stat(33)/8} local tile=fget(mget(m[0],m[1]), 0) dtxt('tile flags', 0, 6*8, c) local res = {} res[1] = fget(mget(m[1],m[2]), 0) res[2] = fget(mget(m[1],m[2]), 1) res[3] = fget(mget(m[1],m[2]), 2) res[4] = fget(mget(m[1],m[2]), 3) res[5] = fget(mget(m[1],m[2]), 4) res[6] = fget(mget(m[1],m[2]), 5) res[7] = fget(mget(m[1],m[2]), 6) res[8] = fget(mget(m[1],m[2]), 7) dtxt('{'.. blton(res[1]) ..','..blton(res[2]) ..','..blton(res[3]) ..','..blton(res[4]) ..'\n '..blton(res[5]) ..','..blton(res[6]) ..','..blton(res[7]) ..','..blton(res[8]) ..'}\ntile-id: '..mget(m[1],m[2]), 0, 6*9, c) print('color: '..pget(m[1]*8,m[2]*8), 0, 6*12, max(pget(m[1]*8,m[2]*8), 1)) circ(stat(32), stat(33), 3, c) circfill(stat(32), stat(33),1, c) end function blton(v) return v and 1 or 0 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=33099 https://www.lexaloffle.com/bbs/?tid=33099 Thu, 31 Jan 2019 03:43:02 UTC RPG tiles [shooting★] (w/sprites) <p>Hey, everyone! Here's some RPG tiles for your project. It includes some sprites, too.</p> <p>You can copy the image data by clicking the 128x32 link text.</p> <p>Screenshots:</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-26 20-37-36.png" alt="" /> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-26 20-37-45.png" alt="" /> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-26 20-25-22.png" alt="" /> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-26 20-25-28.png" alt="" /> <p>image data [<strong>TAB 1</strong>]<br /> <table><tr><td width=0> <img src="https://www.lexaloffle.com/bbs/gfxc/34534_4.png" width=0 height=0> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_34534_4"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/34534_4.txt", function (retdata){ var el = document.getElementById("gfxcode_34534_4"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [0x0]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_34534_4" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> </p> <p>image data [<strong>TAB 2</strong>]<br /> <table><tr><td width=0> <img src="https://www.lexaloffle.com/bbs/gfxc/34534_5.png" width=0 height=0> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_34534_5"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/34534_5.txt", function (retdata){ var el = document.getElementById("gfxcode_34534_5"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [0x0]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_34534_5" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> </p> <p>image data [<strong>TAB 3</strong>]<br /> <table><tr><td width=0> <img src="https://www.lexaloffle.com/bbs/gfxc/34534_6.png" width=0 height=0> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_34534_6"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/34534_6.txt", function (retdata){ var el = document.getElementById("gfxcode_34534_6"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [0x0]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_34534_6" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> </p> <p>image data [<strong>TAB 4</strong>]<br /> <table><tr><td width=0> <img src="https://www.lexaloffle.com/bbs/gfxc/34534_7.png" width=0 height=0> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_34534_7"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/34534_7.txt", function (retdata){ var el = document.getElementById("gfxcode_34534_7"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [0x0]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_34534_7" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> </p> https://www.lexaloffle.com/bbs/?tid=33040 https://www.lexaloffle.com/bbs/?tid=33040 Sun, 27 Jan 2019 02:01:22 UTC Platformer Tiles #1 [Shooting★] <p>Hi, everybody! I'm a new user to this Pico-8 thing but I'm already a big fan of it. I'm having a lot of fun designing things, so here you go~ I may post more tilesets in the future.</p> <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34534/Screenshot from 2019-01-26 20-15-08.png" alt="" /> <p> <table><tr><td> <a href="/bbs/?pid=61247#p"> <img src="/bbs/thumbs/pico8_wguhogib-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=61247#p"> wguhogib</a><br><br> by <a href="/bbs/?uid=34534"> ShootingStar</a> <br><br><br> <a href="/bbs/?pid=61247#p"> [Click to Play]</a> </td></tr></table> </p> <p>DL the cart to use the tiles</p> <p>Alternatively, you can copy the tile data directly. click 128x32 next to the image to copy the data<br /> <table><tr><td width=0> <img src="https://www.lexaloffle.com/bbs/gfxc/34534_3.png" width=0 height=0> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_34534_3"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/34534_3.txt", function (retdata){ var el = document.getElementById("gfxcode_34534_3"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [0x0]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_34534_3" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> </p> https://www.lexaloffle.com/bbs/?tid=33036 https://www.lexaloffle.com/bbs/?tid=33036 Sun, 27 Jan 2019 01:18:26 UTC