I am working on a game that uses an image I drew as the background. I want to be able to scan the image at the location of the player to determine whether I am standing in front of a door or not.
I am using this method to check the pixel color of my image, and it returns the same number no matter where I am standing, so I am obviously using it wrong.
public boolean door(int playerX, int playerY){
System.out.println("pixel color: " + imLd.getImage(ribImages[level-1]).getRGB(playerX, playerY));
if(imLd.getImage(ribImages[level-1]).getRGB(playerX, playerY)== 573128);
isOverDoor = true;
return isOverDoor;
}
this prints “pixel color: -12247529” always.
Here is the call to it in my update method:
ribsMan.door(ninja.locx+ninja.width/2, ninja.locy-150);
//This is just a point I am feeding in that I know is on the door with nothing blocking it.
//I will change it to be not hardcoded once I get it working.