Keyboard input problem

BraveWorks

  • Posts: 48
Ok, I'm wanting to make my eight way movement a lot smoother but there seems to be a problem with the input detection. Moving from a (-,-) direction to a (+,-) direction, the player will naturally press left, up AND right at the same time, I would like to make the 3 keys held together move the character upwards (to make a smoother transition from one diagonal to the other, it really does make a huge difference) BUT stencyl does not seem to read up, left and right at the same time (down, left and right works perfectly) the character simply does not move and input is not registered, is this a flash limitation? or just stencyl and can it be fixed?


dtrungle

  • Posts: 1938
No idea.

Could be your keyboard. Or Stencyl. Or your coding. Take a guess.

BraveWorks

  • Posts: 48
Its not my keyboard, thats functioning perfectly, its not my coding because its simply a reverse of my left, right and down combination, just seems like Stencyl doesn't register those 3 keys as being down at the same time.

gruffman

  • *
  • Posts: 564
I dont quite see why you think pressing UP, RIGHT, LEFT all at the same time should make an actor go upwards. From what I can tell you are asking stencyl to do something really quite odd..

I dont think this is a stencyl limitation. You are probably overthinking your movement. up is up, upleft is upleft etc. Thats all.
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

Tuo

  • *
  • Posts: 2469
Would help to see the coding. For the gentlest transition, just use any of the numerous 8-way movement behaviors that you can find in tutorials, demos, or directly on StencylForge
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

BraveWorks

  • Posts: 48
I dont quite see why you think pressing UP, RIGHT, LEFT all at the same time should make an actor go upwards. From what I can tell you are asking stencyl to do something really quite odd..

I dont think this is a stencyl limitation. You are probably overthinking your movement. up is up, upleft is upleft etc. Thats all.

It does seem like an odd concept but seriously it does really make the feel of the game alot more fluid, it is not just stupid idea I have come up with, it is a commonly used concept in 8 way movement.

BraveWorks

  • Posts: 48
Would help to see the coding. For the gentlest transition, just use any of the numerous 8-way movement behaviors that you can find in tutorials, demos, or directly on StencylForge

It's not  problem with the coding, 100%, I stripped the code down JUST to test the three buttons. "If (down is down) and (left is down) and (right is down)" works perfectly but not with up left and right, Stencyl just doesn't register those keys together.

BraveWorks

  • Posts: 48
And this isnt a problem with me getting 8-way movement, this is a problem with me polishing the movement and making it feel the best I can. It may seem a weird concept but when a player moves from top left to top right movement its a natural progression in which the player presses all 3 keys in between, it makes an angular change of direction into a more fluid arc.

Hectate

  • *
  • Posts: 4645
First, keyboards can have actual hardware limitations that restrict how many keys can be detected at one time. Sections of the keyboard within the same area can only report so many keys pressed - largely dependent on the quality of the keyboard used.

Secondly, if you have code that checks for key presses independent of key press combinations, that might have an impact. For example;

Quote
if ( Right is down)
- move right
else if (Up is down)
- move up
else if (Right is down AND Up is down)
- move diagonally up and right

this code here will never detect the right/up combination. The simple fact is that the logic dictates that if Right is down it should move right and ignore all the other conditionals. While that includes just Up, it also causes the logic to exclude the up/right combination. To fix this, you would need to put the combinations first:

Quote
if (Right is down AND Up is down)
- move diagonally
else if (Right is down)
- move right
else if (Up is down)
- move up

Now by moving the combination to the top it gets checked first and if it's not true it will still continue to check for the individual keys.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

captaincomic

  • *
  • Posts: 6108
It's not  problem with the coding, 100%, I stripped the code down JUST to test the three buttons. "If (down is down) and (left is down) and (right is down)" works perfectly but not with up left and right, Stencyl just doesn't register those keys together.
Some keyboards have problems detecting multiple keypresses at the same time. Of course the common combinations with modifier keys work, but maybe up+left+right is not detected by your keyboard.
http://gaming.stackexchange.com/questions/20449/keyboard-multiple-key-press-problem

Ninja'd while googling for a link...

BraveWorks

  • Posts: 48
Thanks for the info guys, will be very useful now I'm moving into c++ and I would think it would be a coding error. <3

Edit:It is a hardware problem :D thanks captaincomic + Hectate, now is the choice to remap controls or have the movement looking angular and clunky