How to Rotate a 2D Array of Integers

前端 未结 7 1955
栀梦
栀梦 2020-12-15 06:36

I am programming a Tetris clone and in my game I store my tetromino blocks as 4x4 arrays of blocks. I now need to be able to rotate the integer positions in the arrays so th

7条回答
  •  孤城傲影
    2020-12-15 06:57

    I'd store (x, y) coordinates of the "cells" and use rotation matrix to rotate them. See Drawing a Rotated Rectangle for example. You probably have to round the result to closest 0.5 increment.

提交回复
热议问题