public class MapBottom {
BottomRay bottomRay = new BottomRay();
BottomNum bottomNum = new BottomNum();
//绘制方法
void paintSelf(Graphics g) {
g.setColor(Color.green);
//画竖线
for (int i = 0; i <= GameUtil.MAP_W; i++) {
g.drawLine(GameUtil.OFFSET + i * GameUtil.SQUARE_LENGTH,
3 * GameUtil.OFFSET,
GameUtil.OFFSET + i * GameUtil.SQUARE_LENGTH,
3 * GameUtil.OFFSET + GameUtil.MAP_H * GameUtil.SQUARE_LENGTH);
}
//画横线
for (int i = 0; i <= GameUtil.MAP_H; i++) {
g.drawLine(GameUtil.OFFSET,
3 * GameUtil.OFFSET + i * GameUtil.SQUARE_LENGTH,
GameUtil.OFFSET + GameUtil.MAP_W * GameUtil.SQUARE_LENGTH,
3 * GameUtil.OFFSET + i * GameUtil.SQUARE_LENGTH);
}
for (int i = 1; i <= GameUtil.MAP_W; i++) {
for (int j = 1; j <= GameUtil.MAP_H; j++) {
//雷
if (GameUtil.DATA_BOTTOM[i][j] == -1) {
g.drawImage(GameUtil.lei,
GameUtil.OFFSET + (i - 1) * GameUtil.SQUARE_LENGTH + 1,
GameUtil.OFFSET * 3 + (j - 1) * GameUtil.SQUARE_LENGTH + 1,
GameUtil.SQUARE_LENGTH - 2,
GameUtil.SQUARE_LENGTH - 2,
null);
}
//数字
if (GameUtil.DATA_BOTTOM[i][j] >= 0) {
g.drawImage(GameUtil.Images[GameUtil.DATA_BOTTOM[i][j]],
GameUtil.OFFSET + (i - 1) * GameUtil.SQUARE_LENGTH + 1,
GameUtil.OFFSET * 3 + (j - 1) * GameUtil.SQUARE_LENGTH + 1,
GameUtil.SQUARE_LENGTH - 2,
GameUtil.SQUARE_LENGTH - 2,
null);
}
}
}
}
}
JAVA、:扫雷游戏,如何绘制相关组件
最新推荐文章于 2024-11-09 10:41:03 发布