owenashurst / agar.io-clone

Agar.io clone written with Socket.IO and HTML5 canvas
MIT License
2.88k stars 1.12k forks source link

Anything wrong with splice()? #451

Closed whahuzhihao closed 8 years ago

whahuzhihao commented 8 years ago

Hi! I'm reading your code these days and got a doubt about some feature. In server.js deleteFood function, splice will change the whole array members' index. So in the forEach loop, some wrong foods will be removed. Am I right?

whahuzhihao commented 8 years ago

I made a mistake. The foodEaten's elements stand from high to low , so there's no problem with splice.