Advertisement
TheBat

Untitled

Apr 9th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. private Point findItemTwoPoint(Color col1, Color col2, Point p, int tolerance, Point TL, Point BR){
  2. Point out = new Point(0,0);
  3. List<Point> test1 = ImageUtil.getPointsWithColor(Game.getImage(), col1,.05);
  4. List<Point> test2 = ImageUtil.getPointsWithColor(Game.getImage(), col2,.05);
  5. boolean breakable = false;
  6. boolean pointFound = false;
  7. for(int i = 0;i < test1.size();i++){
  8. if((test1.get(i).x > TL.x) && (test1.get(i).y > TL.y)){
  9. if((test1.get(i).x < BR.x) && (test1.get(i).y < BR.y)){
  10. for(int j = 0;j < test2.size();j++){
  11. if((test2.get(j).x > TL.x) && (test2.get(j).y > TL.y)){
  12. if((test2.get(j).x < BR.x) && (test2.get(j).y < BR.y)){
  13. if(Math.abs(test1.get(i).x - test2.get(j).x - p.x) < tolerance){
  14. if(Math.abs(test1.get(i).y - test2.get(j).y - p.y) < tolerance){
  15. out = new Point((int)((test1.get(i).x + test2.get(j).x)/2),
  16. (int)((test1.get(i).y + test2.get(j).y)/2));
  17. pointFound = true;
  18. breakable = true;
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27. if(breakable)break;
  28. }
  29. if(pointFound)return out;
  30. else return new Point(-1,-1);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement