Log In  
Follow
Clemjvdm
[ :: Read More :: ]

Btnp() returns true even when button continuously pressed down

Quick Recap

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, ...
Thanks for your help :)

The code:

This code is in a function (p1()) that I call in _update60

--/jump\--
    if p1.grounded then p1.jumptemp=0 end

    if btnp(⬆️) and p1.jumptemp<2 then 
        p1.dy=0
        p1.dy-=p1.jpp   
        p1.jumping=true
        p1.jumptemp+=1
    end

Simplified code:

--/jump\--

    if btnp(⬆️) and p1.jumptemp<2 then 
        p1.dy=0
        p1.dy-=p1.jpp   
    end

Detailed problem and attempts at troubleshooting

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: "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"(pico 8 fandom).

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#73239 2020-02-19 18:31