rupees [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=80228 Variables as Function arguments <p>hello world.<br /> I think I'm missing something in the custom function realm when it comes to using variables as arguments. I'm trying to pass in a variable that defines one of 6 beams to a function so I can use it for all of the beams but it does not seem to be working and I think I'm trying to do something that might not be allowed in Pico-8. For example I have a custom function to light up this beam and it works great:</p> <img style="margin-bottom:16px" border=0 src="/media/80228/beam5 5_1.gif" alt="" /> <p>..but I need to reuse this to do something similar for 5 more of these beams. I'd like to create a reusable function around the following as I am repeating code:</p> <p>function beam_2()<br /> if mg(35) and p.x&lt;500<br /> then<br /> pal(5,7)<br /> spr(35,384,328) sfx(0)<br /> b2_charge=true<br /> else b2_charge=false pal()<br /> end<br /> if b2_go==true then<br /> pal(5,7)<br /> spr(35,384,328)<br /> pal()<br /> end<br /> end</p> <p>I thought I could get away with using something like the below bm_chg function in place of the beam_2 function but it does not seem to be passing the b2_charge variable when I input it for chg_var.</p> <p>function bm_chg(sp,sx,sy,sc,chg_var,go_var)</p> <p>if mg(sp) and p.x&lt;96 then </p> <pre><code> pal(sc,7) spr(sp,sx,sy) sfx(0) chg_var=true else chg_var=false pal()</code></pre> <p>end</p> <p>if go_var==true then<br /> pal(sc,7)<br /> spr(sp,sx,sy)<br /> pal()<br /> end </p> <p>end</p> <p>I was unable to find any documentation of exactly how this works in the manual and any help would be greatly appreciated. </p> https://www.lexaloffle.com/bbs/?tid=140130 https://www.lexaloffle.com/bbs/?tid=140130 Wed, 07 Feb 2024 03:49:10 UTC Animation speed resetting after loop <img style="margin-bottom:16px" border=0 src="/media/80228/beam3 2_1.gif" alt="" /> <p>I'm hoping someone out there can help me solve the ever increasing speed of my bird animation. The goal is to have the ability to put these bird sprites (spr 39 is the static resting bird sprite) all over the map and as the player gets close to them they are disturbed and fly away. A counter (&quot;birds&quot;) counts them and this counter is used to alter states later in the game. Everything is working except that every bird that is disturbed flaps it's wings faster than the previous bird. Any attempt to reset this just results in the bird not animating at all and floating away motionless which is kind of comical. :P </p> <img style="margin-bottom:16px" border=0 src="/media/80228/beam3 2_2.gif" alt="" /> <p>My update and draw code for these bad bois are below. Any ideas as to how I could get them to fly away at the same animation speed regardless of how many have been disturbed? Newish to coding in general here so I'm probably going about this the wrong way. FYI, sprite 39 and 19 are both static versions of the bird depending on the background they sit in front of. </p> <p>--birds--</p> <p>function u_bird()<br /> -- btimer=0</p> <pre><code>for y = flr(p.y/8)-1,flr(p.y/8)+1 do</code></pre> <p>for x = flr(p.x/8)-1,flr(p.x/8)+1 do</p> <pre><code> if mget(x,y)==39 or mget(x,y)==19 then add(fly,{ ex=x*8, ey=y*8, sp=39, }) if mget(x,y)==39 then mset(x,y,59) elseif mget(x,y)==19 then mset(x,y,38) end birds+=1 end end end </code></pre> <p>for e in all(fly) do</p> <p>e.ey-=.5<br /> e.ex+=.2<br /> e.sp=birdsp </p> <pre><code> if birdsp&lt;43.9 and birdsp&gt;=40.1 then birdsp+=.1 else birdsp=40.1 end </code></pre> <p>end<br /> end </p> <p>function d_bird()</p> <p>for e in all(fly) do<br /> spr(birdsp,e.ex,e.ey)<br /> end </p> <p>end</p> https://www.lexaloffle.com/bbs/?tid=55303 https://www.lexaloffle.com/bbs/?tid=55303 Wed, 13 Dec 2023 02:40:15 UTC jittery player sadness <p> <table><tr><td> <a href="/bbs/?pid=132850#p"> <img src="/bbs/thumbs/pico8_kudojowipa-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=132850#p"> kudojowipa</a><br><br> by <a href="/bbs/?uid=80228"> rupees</a> <br><br><br> <a href="/bbs/?pid=132850#p"> [Click to Play]</a> </td></tr></table> </p> <p>I'm new to PICO-8 here folks but absolutely hooked! I'm having a problem with my player shaking during movement as well as getting caught on my flagged sprites that the player collides with. I know some basics and have compiled this code by watching tutorials and scanning forums for code snippets but I think I am mixing some things that don't play well. I am really going for a smooth player movement vibe so I just added some acceleration rather than an abrupt &quot;p.x+=1&quot; movement style. It doesn't appear to show in my GIF but the player shakes violently during gameplay. Any ideas as to what could be causing this would be greatly appreciated! </p> <img style="margin-bottom:16px" border=0 src="/media/80228/beam1 0 p8_0.gif" alt="" /> https://www.lexaloffle.com/bbs/?tid=53691 https://www.lexaloffle.com/bbs/?tid=53691 Tue, 08 Aug 2023 01:13:20 UTC