Thanks Nabeshin! I just got home from school, so I'll try and test this when I can. What playerstate is intended to do, is be an intiger that denotes the current state of action for the object. I'm using a binary type scaling system, where say:
Base = 0
Walking = 1
Jumping = 2
Attacking = 4
Hurt = 8
etc etc etc, so you can never have duplicates by adding (1+2+3 = 4+2).
So, when you press W, it adds 1 (walking) to the playerstate, indicating that the player is moving, in addition to anything else it's doing. So, if for example, playerstate = 5, your player is moving
and attacking.
What concerns me slightly as to your examples is this:
My solution involves the idea that when, for example, A and W are both pressed, you actually just care about W, because pressing the A key adds or subtracts 0 i.e. doesn't do anything. Using this idea, you'll find a lot of your statements become logically equivalent. As a result, the following code performs more or less the exact same function as the code in your first post (except for potential odd behaviour you might have noticed as a result of using bitwise & instead of &&).
For cases other than just 0 and 1, (Base + Walking), say, 1 and 4, (Walking + Jumping) you
do care about both keys. I havn't experimented with your code, or read it through too closely yet, but I'm concerned that it wouldn't cover both inputs.
It looks good though, and I'm eager to play around with it, and see what tweaking needs to be done, but it looks solid from what I read briefly. Thanks a bunch, and I'll get back to y'all with any further issues on this subject once I play around some!
EDIT:
What I was trying to find was the word bitmask. That's currently what I'm looking to do, with the playerstate, which means I'm googling and rewriting code atm. Will post later.