Changeset 2e798d9 in advance-wars
- Timestamp:
- Jan 21, 2011, 4:50:20 AM (14 years ago)
- Branches:
- master
- Children:
- 082b3cd
- Parents:
- 5d9e7bb
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/advancewars/GameView.java
r5d9e7bb r2e798d9 47 47 48 48 /** Paint to draw the lines on screen. */ 49 private Paint mLinePaint, mTextPaint, mButtonPaint; 49 private Paint mLinePaint, mTextPaint, mButtonPaint, mTilePaint1, mTilePaint2; 50 51 private Map mMap; 50 52 51 53 /** Indicate whether the surface has been created & is ready to draw */ … … 61 63 mHandler = handler; 62 64 mContext = context; 63 64 // Initialize paints for speedometer 65 65 66 mLinePaint = new Paint(); 66 67 mLinePaint.setAntiAlias(true); … … 77 78 mButtonPaint.setTextSize(20); 78 79 mButtonPaint.setTextAlign(Paint.Align.CENTER); 80 81 mTilePaint1 = new Paint(); 82 mTilePaint1.setAntiAlias(true); 83 mTilePaint1.setARGB(255, 0, 255, 0); 84 85 mTilePaint2 = new Paint(); 86 mTilePaint2.setAntiAlias(true); 87 mTilePaint2.setARGB(255, 0, 0, 255); 88 89 Tile grassTile = new Tile(mTilePaint1); 90 Tile oceanTile = new Tile(mTilePaint2); 91 92 mMap = new Map(grassTile, 6, 8); 93 94 boolean land = true; 95 96 for(int x=0; x<mMap.getWidth(); x++) { 97 for(int y=0; y<mMap.getHeight(); y++) { 98 if(land) 99 mMap.setTile(x, y, grassTile); 100 else 101 mMap.setTile(x, y, oceanTile); 102 land = !land; 103 } 104 land = !land; 105 } 79 106 80 107 mGameState = GameState.YOUR_TURN; … … 290 317 Paint.FontMetrics metrics = mTextPaint.getFontMetrics(); 291 318 292 String text = "Your Total: "; 293 canvas.drawText(text, 40-mTextPaint.measureText(text)/2, 450-(metrics.ascent+metrics.descent)/2, mTextPaint); 319 mMap.draw(canvas, 10, 25); 294 320 295 text = "Dealer Total: "; 296 canvas.drawText(text, 125-mTextPaint.measureText(text)/2, 450-(metrics.ascent+metrics.descent)/2, mTextPaint); 297 298 text = mPlayerWins+" wins - "+mPlayerLosses+" losses"; 299 canvas.drawText(text, 270-mTextPaint.measureText(text)/2, 450-(metrics.ascent+metrics.descent)/2, mTextPaint); 321 String text = "Advance Wars grid test"; 322 canvas.drawText(text, 0, 450-(metrics.ascent+metrics.descent)/2, mTextPaint); 300 323 } 301 324
Note:
See TracChangeset
for help on using the changeset viewer.