Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a simple PairCondition class for pairing inputs together #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

greenstack
Copy link

I found myself wanting to be able to pair inputs and check which "side" of the inputs was down, so I put this together. I designed it to depend on other conditions, and based on which condition is met, output -1, 0, or 1.

I was wondering how having both conditions held should react - should they cancel out or should the developer be able to specify a direction that behavior? I think the latter would be good but wanted to put that up for discussion here.

@Apostolique
Copy link
Owner

What is your use case for this? Is it like a joystick where you can move left or right or anywhere in between?

I had started something similar #13.

@greenstack
Copy link
Author

It's similar to #13, yes. Here's are a sample use cases in my project:

WeaponSwap = new PairCondition
(
    new AnyCondition(
        new KeyboardCondition(Keys.A),
        new GamePadCondition(GamePadButton.LeftShoulder, playerIndex)
    ),
    new AnyCondition(
        new KeyboardCondition(Keys.S),
        new GamePadCondition(GamePadButton.RightShoulder, playerIndex)
    )
);

In this case, this is to let the player switch weapons quickly, left or right or up and down.

It's not quite the same as mapping a joystick to an input, but more mapping two related inputs to a single condition. I was inspired by this axis pairs feature from a library for another game framework to make it a bit easier to figure out which "direction" a condition was pointing in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants