Tetris Piece Rotation Algorithm

前端 未结 15 860
傲寒
傲寒 2020-11-30 17:57

What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confu

15条回答
  •  一生所求
    2020-11-30 18:32

    If array size is 3*3 ,than the simplest way to rotate it for example in anti-clockwise direction is:

    oldShapeMap[3][3] = {{1,1,0},
                         {0,1,0},
                         {0,1,1}};
    
    bool newShapeMap[3][3] = {0};
    int gridSize = 3;
    
    for(int i=0;i

提交回复
热议问题