How to Rotate a 2D Array of Integers

前端 未结 7 1952
栀梦
栀梦 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:51

    In classic tetris there are very few permutations of objects. I would simply have a constant array for each "tetromino," at each of the 4 positions, and simple logic to choose the appropriate one based on input.

    Why waste CPU cycles trying to rotate it?

提交回复
热议问题