Changeset 2e798d9 in advance-wars for src


Ignore:
Timestamp:
Jan 21, 2011, 4:50:20 AM (14 years ago)
Author:
sdanshinwrt <devnull@…>
Branches:
master
Children:
082b3cd
Parents:
5d9e7bb
Message:

-A simple 6x8 map now gets drawn to the screen, with green and blue tiles

-Added the bin folder to .hgignore

Location:
src/com/example/advancewars
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/com/example/advancewars/GameView.java

    r5d9e7bb r2e798d9  
    4747
    4848        /** 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;
    5052
    5153        /** Indicate whether the surface has been created & is ready to draw */
     
    6163            mHandler = handler;
    6264            mContext = context;
    63 
    64             // Initialize paints for speedometer
     65           
    6566            mLinePaint = new Paint();
    6667            mLinePaint.setAntiAlias(true);
     
    7778            mButtonPaint.setTextSize(20);
    7879            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            }
    79106           
    80107            mGameState = GameState.YOUR_TURN;
     
    290317                Paint.FontMetrics metrics = mTextPaint.getFontMetrics();
    291318               
    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);
    294320               
    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);
    300323        }
    301324
Note: See TracChangeset for help on using the changeset viewer.