Furthermore, the problem isn't the bad English in itself; the problem is you're not clearly explaining what the problem is. The only parts that that look even close to code are drawBox(= tra_x,=tra_y,=tra_z and foo = tra_x;, the first of which isn't even C++.
Your game should have some sort of event loop or message callback that receives input, e.g. if you press down a key, this triggers an event. Perhaps during this event, you simply set a bool down = true. Then, in the main logic for that frame, if down is currently true, move the player down
e.g.
1 2 3 4
if (down)
{
player.y -= some_delta_amount; // depending on coordinate system, this might be +=
}
During a "key released" event, you would then set down = false, and the player will no longer move.
you could do this. I don't know if it is appropriate to your question.
void foo ( vector xyz, bool update = false)
{
if(update)
something = xyz; //whatever update statement(s) could be complicated etc.
//this could also be return; statement to do nothing at all if there is nothing to do.
//that seems kinda lame, better to not call the function if it won't do anything, if possible.
other_code();
}
if you call it with
foo(abc); // will not update
foo(abc, false); //will not update
foo(abc, true); //WILL UPDATE
and you can get snarky..
foo(abc, oldabc!=abc); //will update if oldabc != abc, that is, the expression is true.
i need say this.
I want build a box with drawBox(x,y,z)
and i want be x y z same as my player position.
But when player moves the box follows me i don't want that.
I don't want box follow me.
So... you want x, y, z to be the initial player position, but when the player moves, you don't want x, y, z to be updated to reflect the new player position?
then the 2 things need distinct coordinates, and they are initialized to the same value, and tracked distinctly. There may be oddball things you could do in weird circumstances, eg if the box is fixed and the player moves, you can define the box at a local 0,0,0 coordinate and the player as offsets to that (giving you the distance the player is from the box easily, or whether he is inside the box easily, and so on, if that is the goal ... with one size zeros you can do less math to get some answers). But its really just as easy to stay in the global coordinate system unless you see a meaningful reason to do otherwise.