How do I fully convert key inputs into variables

From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • Hello!

    So I am making a platformer and the complexity of it is pretty absurd right now, what I mean by it, the main character has about 20 animations, each with 20+ frames and whatnot. I am trying to do some stunning pixel art, and so far I am quite happy everything is a smooth as you'd expect in a professionally done game. I have achieved this with the use of 120+ events just for the main character, and I have done my best to keep the the events as clean as possible, with a few nasty exceptions I felt I had to do because I could not see any solution, but I feel that after having gone through all that (and learned new things on the way), I am confident I can make it ever simpler.

    I would like to start from scratch to see if I can make the events structure even smoother and avoid the massive headaches I encounter whenever a bug arises.

    First of all I want to ask if the use of variables for input controls is the best way of doing this, so I write a list of events which determines each control state (up:0, Up:1, Left:0 Left:1 and so on), then I map each individual keyboard or joypad button to those variable events, that way I can control the movement and character interaction events using only variables instead of "key pressing" functions. I am asking if this is the best way because I have noticed that variables sometimes seems to react a little slower than direct input controls, I remember finding an issue which was caused by a variable not switching fast enough, then when I I changed it to a direct keyboard control the issue was gone.

    I am also asking this because I am not sure how would I simulate "on press" with variables, I mean "is down" is pretty simple, the variable is either 0 or 1, but how do you register through variable "the moment they variable is switching to 1 from 0"?

    I think this is all, thanks in advance and sorry about the long wall of text!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You don't need variables, you just use 'key is down' or 'on key pressed' which themselves are like booleans. Also how on earth did you use 120 events for character movement in a platformer?

  • It has more animations/functions than Alucard and Samus combined :D

    That includes rotating animations while running, events which allows the character to play an animation when it lands from a certain speed while doing a different animation from another speed. Difference in jumps depending if you are running or standing still, same with falling and so on.

    Also, key down and what not are useless when you give the player the freedom to remap every control. I have actually found a way to make this work with the keyboard no problem, now I only need to find a solution for the game pad which seems not to have a functionality to call a key press based on a number.

    Edit: Solved it with controller too, the only thing I have noticed is that both the analog sticks have key codes for +X and +Y but do not have key codes for the opposite directions (I am using a key call function to identify each button code), I wonder why.

  • Alright then :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)