I am very new to JS.
Was studying this tutorial (https://youtu.be/0ArCFchlTq4). Have noticed something interesting in this project, and it's bothering me a lot. May be someone can help me to come up with some answers.
There is this part of code, in which we shift the array of pipes (code listed below). But after the shift, the leftmost pipe makes this wierd thing - it's holds the movement for brief moment, making pipeline visually shift few pixels backwards relative to foreground, for example, which is moving with the same speed as pipes. This happens in the same moment as shift command is executed, and affects only the next pipe in array.
Will be so happy if someone can explain this to me, and maybe give a hint on a fix. Thank you!
// if the pipes go beyond canvas, we delete them from the array
if(p.x + this.w<= 0){
this.position.shift();
score.value += 1;
SCORE_S.play();
score.best = Math.max(score.value, score.best);
localStorage.setItem("best", score.best);
}
}
},
reset : function(){
this.position = [];
}
}