Web
Analytics
Log In  

1

In my latest game, I rely on a press of both buttons to restore health. But players (including myself) have been complaining that this behaves inconsistently.

I am using code along the lines of:

if(btnp(4) and btnp(5))then
       plr.usepotion(plr);
     elseif(btnp(4))then
       if(plr.stm>1)then
        plr.commanddash(plr)
        plr.stm-=10
       else
        sfx(18)
       end
     elseif(btnp(5)) then
       if(plr.stm>1)then
        plr.attack(plr)
         plr.stm-=5
       else
        sfx(18)
       end
    end

Its just too inconsistent though. I've had comments wishing there was a third button.

P#50395 2018-03-14 07:21 ( Edited 2018-03-14 16:25)

::

You can try it on my game here:

P#50396 2018-03-14 07:26

::

So the way that's written, they need to press X and O in the same frame to use a potion. If you do this instead...

if btn(🅾️) then
    if btnp(❎) then
        ... use potion code here ...
    end
end

..it will make it so they just have to press ❎ while they're holding 🅾️ to use a potion.

FYI you can now use ❎ and 🅾️ in code instead of 4/5. To type them in the pico-8 editor, hold shift when pressing X or O.

You may want to do something like this...

if btn(❎) and btnp(🅾️) then
    ... use potion code here ...
elseif btn(❎) then
    ... attack code ...
elseif btnp(🅾️) then
    ... dash code ...
end

that would make it so that you always attack when you first press the ❎ button. If you press 🅾️ without holding ❎, you'll dash. And if you press 🅾️ after you've started holding down ❎, you'll use a potion.

The other option would be to add a menu. There's a built-in pause menu ('P' on the keyboard) you can add things to using menuitem().

P#50402 2018-03-14 10:25 ( Edited 2018-03-14 10:32)

::

Ah thanks for your reply, that's great, never thought to check them one by one.

P#50411 2018-03-14 16:25

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-09-19 16:28 | 0.222s | 1572k | Q:15