Jump to content

  • Log In with Google      Sign In   
  • Create Account


MattFF

Member Since 28 Sep 2012
Offline Last Active Nov 14 2012 08:43 AM
-----

Topics I've Started

Handling input properly in 2d brawler

28 September 2012 - 03:25 AM

Hi guys!

I am currently in process of making a 2d side-scrolling fighting game. I'm using SFML for that purpose.

Problem i've ran into is handling input. ATM i'm passing states depending on key presses to the hero class, which then animates and moves main character properly. Display and move member functions are based on switch.

Problems i currently have:

1) It seems that sooner rather than later the switch will be overblown and hard to manage.
2) Animations are running only when key is pressed. I am not quite sure how to manage actions on key release. For example: When you run, then release, there should be a couple frames of animation of stopping, and returning to basic stance. I can't run the animation within the button press event with some kind of loop, because it executes instantly and jumps to last frame.
3)In general, i'm not sure where in the code should i place the input check. In the main loop? Or in some kind of interface manager? I imagine they shouldn't be in the hero class, it should recieve only states based on presses.

I would appreciate any help.

PARTNERS