I am making a program which auto-plays a game called bemuse. Currently, I have all of the components set up, however, I am having determining if the color block is over the area that you hit it in.
I tried using the distance formula that was provided in a thread that had a similar question, but I am consistently getting wrong results.
boolean similarTo(Color c,Color v){
double distance = Math.sqrt((c.getRed() - v.getRed())*(c.getRed() - v.getRed()) + (c.getGreen() - v.getGreen())*(c.getGreen() - v.getGreen()) + (c.getBlue() - v.getBlue())*(c.getBlue() - v.getBlue()));
// double average1 = c.getRed()+c.getBlue()+c.getGreen();
// double average2 = v.getRed()+v.getBlue()+v.getGreen();
if(distance < 100 ){
return true;
}else{
return false;
}
}
Using this it should press when the pixel becomes similar, but the results always differ such as it saying that they are the same all the time, of never updating.