From 70c9da4edb8240cd472dc96ba6beaedd57c42ca4 Mon Sep 17 00:00:00 2001 From: gitknilch Date: Fri, 5 Apr 2013 15:16:35 +0200 Subject: [PATCH] fix access to tile width and height Change-Id: Id3fc7f8a36ab8a48a3e370c6f21d0f2e1b17bd9a Signed-off-by: gitknilch --- src/de/cwde/freeshisen/ShisenShoView.java | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/de/cwde/freeshisen/ShisenShoView.java b/src/de/cwde/freeshisen/ShisenShoView.java index a326fa6..3dc6ff0 100644 --- a/src/de/cwde/freeshisen/ShisenShoView.java +++ b/src/de/cwde/freeshisen/ShisenShoView.java @@ -42,8 +42,6 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { private int screenWidth; private int screenHeight; - private int tileHeight; - private int tileWidth; private Bitmap bg; private Point selection1 = new Point(0, 0); private Point selection2 = new Point(0, 0); @@ -280,8 +278,8 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { int y0=0; if (app!=null && app.board!=null) { - x0=(screenWidth-app.board.boardSize[1]*tileWidth)/2; - y0=(screenHeight-app.board.boardSize[0]*tileHeight)/2; + x0=(screenWidth-app.board.boardSize[1]*tileset.tileWidth)/2; + y0=(screenHeight-app.board.boardSize[0]*tileset.tileHeight)/2; } int selectcolor = Color.parseColor(COLOR_SELECTED); @@ -314,7 +312,11 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { // Tiles are 56px height, 40px width each char piece=app.board.board[i][j]; if (piece!=0) { - canvas.drawBitmap(tileset.tile[piece], x0+j*tileWidth, y0+i*tileHeight, null); + canvas.drawBitmap( + tileset.tile[piece], + x0+j*tileset.tileWidth, + y0+i*tileset.tileHeight, + null); } } } @@ -437,10 +439,10 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { paint.setStrokeJoin(Join.ROUND); paint.setStrokeWidth(3); canvas.drawLine( - x0 + p0.j * tileWidth - 2 + (tileWidth / 2), - y0 + p0.i * tileHeight - 2 + (tileHeight / 2), - x0 + p1.j * tileWidth - 2 + (tileWidth / 2), - y0 + p1.i * tileHeight - 2 + (tileHeight / 2), paint); + x0 + p0.j * tileset.tileWidth - 2 + (tileset.tileWidth / 2), + y0 + p0.i * tileset.tileHeight - 2 + (tileset.tileHeight / 2), + x0 + p1.j * tileset.tileWidth - 2 + (tileset.tileWidth / 2), + y0 + p1.i * tileset.tileHeight - 2 + (tileset.tileHeight / 2), paint); } private void highlightTile(Canvas canvas, int x0, int y0, Point p, int color) { @@ -452,10 +454,10 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { paint.setStrokeJoin(Join.ROUND); paint.setStrokeWidth(3); Rect r = new Rect( - x0 + p.j * tileWidth - 2, - y0 + p.i * tileHeight - 2, - x0 + p.j * tileWidth + tileWidth + 2, - y0 + p.i * tileHeight + tileHeight + 2); + x0 + p.j * tileset.tileWidth - 2, + y0 + p.i * tileset.tileHeight - 2, + x0 + p.j * tileset.tileWidth + tileset.tileWidth + 2, + y0 + p.i * tileset.tileHeight + tileset.tileHeight + 2); canvas.drawRect(r, paint); } @@ -469,8 +471,8 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { private void onClick(int x, int y) { try { - int i=(y-(screenHeight-app.board.boardSize[0]*tileHeight)/2)/tileHeight; - int j=(x-(screenWidth-app.board.boardSize[1]*tileWidth)/2)/tileWidth; + int i=(y-(screenHeight-app.board.boardSize[0]*tileset.tileHeight)/2)/tileset.tileHeight; + int j=(x-(screenWidth-app.board.boardSize[1]*tileset.tileWidth)/2)/tileset.tileWidth; switch (cstate) { case IDLE: -- 2.39.5