【问题标题】:Offset Rotation偏移旋转
【发布时间】:2013-10-09 13:01:18
【问题描述】:

我有一段代码可以在俄罗斯方块游戏中旋转一块,但我不知道 xOffset 和 yOffset 变量的含义。你能为我解释更多吗?非常感谢!!

双 xOffset = 宽度/2.0 - .5; 双 yOffset = 高度/2.0 - .5;

    //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); 

【问题讨论】:

    标签: java rotation offset


    【解决方案1】:

    仅通过读取 sn-p 很难判断,但在我看来 xOffsetyOffset 值是指旋转的中心点。

    【讨论】:

      猜你喜欢
      • 2010-12-17
      • 2011-12-20
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      • 1970-01-01
      • 2015-01-13
      相关资源
      最近更新 更多