Diagonal Player Key Inputs

maxman

Well-known member
I'm just wondering if going with diagonal key inputs would be possible to press, hold, or release. My idea for the diagonal key input is this with diagonal down forward. For example, Ryo does the charge with diagonal back down before performing Hien Shippuu Kyaku (with forward attack). I could use Piccolo's Daimao Cancel script system for charging, but I don't know if diagonal key inputs is possible.

Code:
playerkeys(iPIndex, 0, ("moveleft" + "movedown") || ("movedown" + "moveleft")); // Diagonal duck backward

Or is it this?

Code:
playerkeys(iPIndex, 0, (("moveleft" + "movedown") || ("movedown" + "moveleft"))); // Diagonal duck back
 
White Dragon's system is awesome, but you don't even have to go that far if you want to look for more than one key (which is what diagonal is).

OpenBOR's keys are bitwise ints. IOW, you can use a Bitwise AND to evaluate which keys are being pressed. I find this to be far simpler and more versatile than bothering with playkeys. Here's an easy example:

Code:
#define KEY_MOVE_UP       openborconstant("FLAG_MOVEUP")
#define KEY_MOVE_RIGHT      openborconstant("FLAG_MOVERIGHT")

// Get current key press and any keys being held.
    key_hold        = getplayerproperty(player_index, "keys");
    key_press       = getplayerproperty(player_index, "newkeys");

// Holding up and right?
if(key_hold & KEY_MOVE_UP && key_hold & KEY_MOVE_RIGHT)
{
     //....do stuff...
}
 
Wow! I didn't know openborconstant has flag move inputs (FLAG_MOVEUP, FLAG_MOVELEFT, etc.). That makes me wonder more on what openborconstant has currently updated as not seen in the manual. Now I'm wondering also about any updates on the SourceForge for OpenBOR.

For using keys and newkeys, do I not have to use int if I want to call out the variable names?

Example:

Instead of this:

Code:
int key_hold        = getplayerproperty(player_index, "keys");

I can go with variable name without function name (void, int, char, etc.)?

Code:
key_hold        = getplayerproperty(player_index, "keys");

Now I see the difference and similarities with newkeys and keys. keys plays similar to 0 for holding keys in playkeys/playerkeys, while newkeys is much like 1 for presses. From looking at what you #define'd, you defined a name with any function that makes sense, like, you named KEY_MOVE_UP and defined it as openborconstant("FLAG_MOVEUP") for going with up flag. It's just like defining the name cep for changeentityproperty.

I notice key_lib got recently updated a while ago. Thanks White Dragon for the update.

Thanks DC for a simple diagonal input example.

EDIT: Never mind. I have to go with int first.
 
I see we got "keys" for holding and "newkeys" for pressing. But what about for releasing? Should I change the "keys" player property for releasing like this?

Code:
changeplayerproperty(PIndex, "newkeys", 1);

Anyway, what does "hasplayed" mean? Is it for releasing or something? We have a list of player property here.

Code:
        "colourmap",
        "credits",
        "ent",
        "entity",
        "hasplayed",
        "keys",
        "lives",
        "name",
        "newkeys",
        "playkeys",
        "score",
        "spawnhealth",
        "spawnmp",
        "weapon",
        "weapnum",
 
Back
Top Bottom