Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Point findItemTwoPoint(Color col1, Color col2, Point p, int tolerance, Point TL, Point BR){
- Point out = new Point(0,0);
- List<Point> test1 = ImageUtil.getPointsWithColor(Game.getImage(), col1,.05);
- List<Point> test2 = ImageUtil.getPointsWithColor(Game.getImage(), col2,.05);
- boolean breakable = false;
- boolean pointFound = false;
- for(int i = 0;i < test1.size();i++){
- if((test1.get(i).x > TL.x) && (test1.get(i).y > TL.y)){
- if((test1.get(i).x < BR.x) && (test1.get(i).y < BR.y)){
- for(int j = 0;j < test2.size();j++){
- if((test2.get(j).x > TL.x) && (test2.get(j).y > TL.y)){
- if((test2.get(j).x < BR.x) && (test2.get(j).y < BR.y)){
- if(Math.abs(test1.get(i).x - test2.get(j).x - p.x) < tolerance){
- if(Math.abs(test1.get(i).y - test2.get(j).y - p.y) < tolerance){
- out = new Point((int)((test1.get(i).x + test2.get(j).x)/2),
- (int)((test1.get(i).y + test2.get(j).y)/2));
- pointFound = true;
- breakable = true;
- break;
- }
- }
- }
- }
- }
- }
- }
- if(breakable)break;
- }
- if(pointFound)return out;
- else return new Point(-1,-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement