@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawBoard(canvas);
drawPieces(canvas);
checkGameOver();
}
private void drawPieces(Canvas canvas) {
for (int i=0,n=mWhiteArray.size();i<n;i++){
Point whitePoint=mWhiteArray.get(i);
canvas.drawBitmap(mWhitePiece,
(whitePoint.x+(1-radtioPieceOfLineHeight)/2)*mLineHeight,
(whitePoint.y+(1-radtioPieceOfLineHeight)/2)*mLineHeight,null);
}
for (int i=0,n=mBlackArray.size();i<n;i++){
Point blackPoint=mBlackArray.get(i);
canvas.drawBitmap(mBlackPiece,
(blackPoint.x+(1-radtioPieceOfLineHeight)/2)*mLineHeight,
(blackPoint.y+(1-radtioPieceOfLineHeight)/2)*mLineHeight,null);
}
}
private void drawBoard(Canvas canvas){
int w=mPanelWidth;
float lineHeight=mLineHeight;
for (int i=0;i<MAX_LINE;i++){
int startX= (int) (lineHeight/2);
int endX= (int) (w-lineHeight/2);
int y= (int) ((0.5+i)*lineHeight);
canvas.drawLine(startX,y,endX,y,mPaint);
canvas.drawLine(y,startX,y,endX,mPaint);
}
}