Fill screen around sniper aim

This commit is contained in:
Victor 2014-02-26 14:00:33 +02:00
parent 6ac559a635
commit e032a9cba5

View File

@ -9,6 +9,7 @@ import com.annimon.jecp.Image;
public class SniperAim {
private final Image aim;
private final int aimWidth, aimHeight;
private final int width, height;
private int x, y;
@ -16,11 +17,20 @@ public class SniperAim {
this.width = width;
this.height = height;
aim = ImageLoader.load(ImageLoader.SNIPER_AIM);
x = (width - aim.getWidth()) / 2;
y = (height - aim.getHeight()) / 2;
aimWidth = aim.getWidth();
aimHeight = aim.getHeight();
x = (width - aimWidth) / 2;
y = (height - aimHeight) / 2;
}
public void draw(Graphics g) {
g.drawImage(aim, x, y);
g.setColor(0xFF000000);
final int bottom = y + aimHeight;
g.fillRect(0, 0, width, y);
g.fillRect(0, bottom, width, height - bottom);
final int right = x + aim.getWidth();
g.fillRect(0, y, x, aimHeight);
g.fillRect(right, y, width - right, aimHeight);
}
}