I have a grid based game 8 squares by 8 squares giving 64 pieces in total, these pieces are stored in an array. I'm having a problem where certain grid squares are being populated twice so I need to check the array for duplicate co-ordinates.
Below code gives the x, y grid co-ordinates of each piece - testX and testY, I'm not sure how I would go about running through this array to remove duplicates. If there are duplicates pieces I need to keep the first encountered and remove any subsequent duplicates. I'm using jQuery if that helps.
function checkGrid() {
var x;
for (x = 0; x < grid.length; x++) {
var testY= grid[x].getY();
var testX = grid[x].getX();
}
}