From what I can gathered about duplicate code, it is if the list of code that occurs more than once. Okay, based on what context? Is a duplicate code based on the similar appearance of the code?
In the below case, I have a character state animation driven by key press events and enum that hold states or behavior denoted by constants.
The reason is the first and second code are the similar in appearance and in functionality but they used different state and key presses to execute this functionality of the game character.
if(direction == Direction.RIGHT && state == ActionState.RUNNING)
{
runRightAnim.update();
if(rightReleased)
{
state = ActionState.IDLE;
}
}
if(direction == Direction.LEFT && state == ActionState.RUNNING)
{
runLeftAnim.update();
if(leftReleased)
{
state = ActionState.IDLE;
}
}