final DesktopScreenRegion s = new DesktopScreenRegion(b.x, b.y, b.width, b.height);
// Finding color stars
Target blueTarget = new ColorImageTarget(Images.BlueStar);
Target redTarget = new ColorImageTarget(Images.RedStar);
Target greenTarget = new ColorImageTarget(Images.GreenStar);
List<ScreenRegion> blueTargetRegions = s.findAll(blueTarget);
List<ScreenRegion> greenTargetRegions = s.findAll(greenTarget);
List<ScreenRegion> redTargetRegions = s.findAll(redTarget);
for (ScreenRegion r : blueTargetRegions){
canvas.addBox(r);
canvas.addLabel(r, "blue");
}
for (ScreenRegion r : redTargetRegions){
canvas.addBox(r);
canvas.addLabel(r, "red");
}
for (ScreenRegion r : greenTargetRegions){
canvas.addBox(r);
canvas.addLabel(r, "green");
}
canvas.display(3);
simulator.resume();
canvas.clear();
// Finding color bullets
ScreenRegion greenBullet = s.wait(new ColorImageTarget(Images.GreenBullet),10000);
ScreenRegion redBullet = s.find(new ColorImageTarget(Images.RedBullet));
ScreenRegion silverBullet = s.find(new ColorImageTarget(Images.SilverBullet));
canvas.addBox(greenBullet);
canvas.addLabel(Relative.to(greenBullet).topLeft().above(20).getScreenLocation(), "green");
canvas.addBox(redBullet);