我罗斯方块汇报1

这个作业属于哪个课程 面向对象程序设计
这个作业要求在哪里 我罗斯方块汇报(1)
这个作业的目标 1.初始游戏界面=表格的绘制+每一次表格的刷新
组员 031902104郭海龙 031902101陈金波 031902130殷宇轩
1.初始界面设计
void DrawPanel(HDC hdc){        //绘制游戏面板
    int x,y;
    RECT rect;
 
    for(y=0;y<ROWS;y++){
        for(x=0;x<COLS;x++){
            //计算方块的边框范围
            rect.top=y*CELL+1;
            rect.bottom=(y+1)*CELL-1;
            rect.left=x*CELL+1;
            rect.right=(x+1)*CELL-1;
            FrameRect(hdc,&rect,(HBRUSH)GetStockObject(BLACK_BRUSH));
        }
    }
}  }
}
void RefreshPanel(HDC hdc){         //刷新面板
    int x,y;
    RECT rect;
    HBRUSH h_bSolid=(HBRUSH)GetStockObject(GRAY_BRUSH),
        h_bEmpty=(HBRUSH)GetStockObject(WHITE_BRUSH);
    if(NULL==block)return;
 
    //先刷屏
    for(y=0;y<ROWS;y++){
        for(x=0;x<COLS;x++){
            //为避免刷掉方块的边框,rect范围必须比边框范围小1
            rect.top=y*CELL+2;
            rect.bottom=(y+1)*CELL-2;
            rect.left=x*CELL+2;
            rect.right=(x+1)*CELL-2;
            if(g_panel[y][x])
                FillRect(hdc,&rect,h_bSolid);
            else
                FillRect(hdc,&rect,h_bEmpty);
        }
    }
    //再定位方块
    for(y=0;y<height_block;y++){
        for(x=0;x<width_block;x++){
            if(*(block+y*width_block+x)){       //实心
                rect.top=(y+cur_top)*CELL+2;
                rect.bottom=(y+cur_top+1)*CELL-2;
                rect.left=(x+cur_left)*CELL+2;
                rect.right=(x+cur_left+1)*CELL-2;
                FillRect(hdc,&rect,h_bSolid);
            }
        }
    }
}

2.接下来计划

void DoDownShift(HDC hdc);      //下移
void DoLeftShift(HDC hdc);      //左移
void DoRightShift(HDC hdc);     //右移
void DoAccelerate(HDC hdc);     //加速

完成这四类的代码

posted @ 2020-05-22 22:17  Mr-CaoMei  阅读(191)  评论(0编辑  收藏  举报