hi,
well first of all, i am new to programing so don't flame for my poor programing, the point here is the logic i think.
so here it goes.
the keyboard component class(need major improvements)
Code:
class KeyboardComponentClass
{
KB_BUTTON button; // keyboard key
DIR_ENUM button_function; // function that is suposed to be performed
KeyboardComponentClass(KB_BUTTON kbb,DIR_ENUM bf){button=kbb; button_function=bf;} // can only construct with both
KB_BUTTON getbtn() // getcurrent key based on function
{
return button;
}
// validation are missing(same key used for 2 distinct function like W used to forward and backward... can't be alloed)
void newbtnfunction(KB_BUTTON b)
{
button=b;
}
}
so with this class, you can add this line to your player class.
these are the default value, this can be read/setup from/on Gui editor on your options window.
Code:
KeyboardComponentClass forward(KB_W,DIRE_FORWARD),left(KB_A,DIRE_LEFT),backward(KB_S,DIRE_BACK),right(KB_D,DIRE_RIGHT);
so after this you can change these lines on your player class
replace this
Code:
input.move.x=Kb.b(KB_D)-Kb.b(KB_A);
input.move.z=Kb.b(KB_W)-Kb.b(KB_S);
Code:
input.move.x=Kb.b(right.getbtn())-Kb.b(left.getbtn());
input.move.z=Kb.b(forward.getbtn())-Kb.b(backward.getbtn());
so now to change for example the forward function you call
Code:
Players[0].forward.newbtnfunction(KB_UP);
after this you UP key is the new forward key in game.
do you understand the logic ? if so from here you just need to create a new class to old 1 array of KeyboardComponentClass so that its easier to manage, or maybe no need for array not sure yet.
hope it helps.