I am learning game programming. I am trying to make a game similar to Pacman. I have made a grid with x[] and y[] (no using tiled). when sprite is in a specific grid I want to destroy its food item which is an image within the grid and add 1 to score. I tried to use image.destroy(); method but it didn't worked.
I tried, instead of destroying the image to change its location.
image.drawImage(image,x+25,y+25);
it only created a new object for as long as I was inside the specific grid.
The Game loop would not let me destroy the image or move it outside the screen.
I also tried
if(sprite is in grid){score=score+1;}
So once the sprite is in grid the score keeps on incrementing. I just want increment of "1" once my sprite is in specific grid.
Any help would be highly appreciated. Thanks.