Java 偏移旋转
我有一个在俄罗斯方块游戏中旋转棋子的代码,但我不知道xOffset和yOffset变量的含义。你能给我解释一下吗?非常感谢 双xOffset=宽度/2.0-.5; 双Y偏移=高度/2.0-.5Java 偏移旋转,java,rotation,offset,Java,Rotation,Offset,我有一个在俄罗斯方块游戏中旋转棋子的代码,但我不知道xOffset和yOffset变量的含义。你能给我解释一下吗?非常感谢 双xOffset=宽度/2.0-.5; 双Y偏移=高度/2.0-.5 //Create a new body TPoint[] newBody = copyBody(body); for(TPoint p : newBody){ //Rotoate 90 degrees counter clockwise about the ori
//Create a new body
TPoint[] newBody = copyBody(body);
for(TPoint p : newBody){
//Rotoate 90 degrees counter clockwise about the origin
double newX = p.x;
double newY = p.y;
newX -= xOffset;
newY -= yOffset;
double temp = newX;
newX = -newY;
newY = temp;
newX += yOffset;
newY += xOffset;
p.x = (int) newX;
p.y = (int) newY;
}
return new Piece(newBody);
仅仅通过阅读片段很难判断,但在我看来,
xOffset
和yOffset
值指的是旋转的中心点