0

我正在Gridworld中设计俄罗斯方块游戏。以下是产生错误的方法。它是 Block 类的一个方法,是一个可以调用移动和旋转方法的 Actor 的集合。 myBlocks是 BlockSection 的 ArrayList。

public boolean canMoveDown() {
    Grid<Actor> g = myBlocks.get(0).getGrid();

    for (BlockSection b : myBlocks) {
        Location l = b.getLocation().getAdjacentLocation(180); // Error occurs here
        System.out.print(l);
        Actor bs = g.get(l);

        // Checks if a section of the block is at the bottom of grid,
        // and then whether, if there is a block below, if it is not
        // part of the current block floating down.
        if (b.getLocation().getRow() == 19 || (bs != null && myBlocks.indexOf(bs) == -1))
            return false;
        }
            return true;
        }
    }
}

我尝试插入一个打印语句以确保 Location 不为空(它不应该为空,因为所有被检查的 BlockSection 都在网格中)并且它确认该值不为空。但是,错误继续产生。帮助?

谢谢

4

0 回答 0