Clemjvdm [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=42033 btnp acting like btn <h1>Btnp() returns true even when button continuously pressed down</h1> <h2>Quick Recap</h2> <p>Essentially when I use btnp() for jumping, when keeping the button pressed down my character jumps, then pauses for a variable amount of time, then jumps again, ...<br /> Thanks for your help :)</p> <h3>The code:</h3> <p>This code is in a function (p1()) that I call in _update60</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>--/jump\-- if p1.grounded then p1.jumptemp=0 end if btnp(⬆️) and p1.jumptemp&lt;2 then p1.dy=0 p1.dy-=p1.jpp p1.jumping=true p1.jumptemp+=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> <h3>Simplified code:</h3> <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>--/jump\-- if btnp(⬆️) and p1.jumptemp&lt;2 then p1.dy=0 p1.dy-=p1.jpp end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h2>Detailed problem and attempts at troubleshooting</h2> <p>Hi everyone, so I'm quite new to pico-8, making my second game which is a platformer. To jump I used BTNP(up) which I believe is meant to: &quot;return true only if a given button was pressed just now, and does not report true again for the same button in the next frame even if it is held down&quot;(pico 8 fandom). </p> <p>But for some reason, when I tried it in my game, when I hold the button down it jumps, waits for a variable amount of time, and jumps again (and so on but I have a double jump limit). I'm not sure why I already figured my key might be a bit dis-functioning but I used a keyboard checker and it seems to be ok. So I'm thinking it has to be something in my code, if you guys know what's wrong please help me :)</p> https://www.lexaloffle.com/bbs/?tid=36866 https://www.lexaloffle.com/bbs/?tid=36866 Wed, 19 Feb 2020 18:31:06 UTC