J2ME游戏代码示例——俄罗斯方块(2)

http://tech.ddvip.com   2008年09月08日    社区交流

本文详细介绍J2ME游戏代码示例——俄罗斯方块(2)

  * 绘制当前下落的方块

   * @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 = "下一个方块";
   /**

  * 绘制下一个方块

   * @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 = "当前得分:";
   /**

作者:陈跃峰    责编:豆豆技术应用

正在加载评论...