J2ME Game code Example--Tetris (2)

Source: Internet
Author: User

* Draw the current whereabouts of the square

* @param g 画笔
   */
   public void paintBrick(Graphics g){
        for(int row = 0;row < 4;row++){
            for(int col = 0;col < 4;col++){
                 //判断是否绘制
                 if(brick[brickType][index][row][col] == 1){
                      int cx = (cCol + col) * CELLWIDTH;
                      int cy = (cRow + row) * CELLWIDTH;
                      paintCell(g,cx,cy);
                 }
            }
        }
   }
   /**下一个方块左上角的x坐标*/
   int nextBrickX = 110;
   /**下一个方块左上角的y坐标*/
   int nextBrickY = 30;
   /**下一个方块文字*/
   String str = "下一个方块";
   /**

* Draw the next square

* @param g 画笔
   */
   public void paintNextBrick(Graphics g){
        //绘制文字
        g.drawString(str, nextBrickX, nextBrickY,
                 Graphics.LEFT | Graphics.TOP);
        //绘制方块
        for(int row = 0;row < 4;row++){
            for(int col = 0;col < 4;col++){
                 //判断是否绘制
                 if(brick[nextBrickType][0][row][col] == 1){
                      int cx =nextBrickX+ col * CELLWIDTH;
                      int cy =nextBrickY + 20 + row * CELLWIDTH;
                      paintCell(g,cx,cy);
                 }
            }
        }
   }
   String scoreStr = "当前得分:";
   /**

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.