コード例 #1
0
    // tells how far apart two GameObjects are
    public double distanceTo(GameObject other)
    {
        GameObject g1 = this;
        GameObject g2 = other;
        GameShape  s1 = g1.getShape();
        GameShape  s2 = g2.getShape();

        double[] offset = new double[2];
        offset[0] = g2.getCenter()[0] - g1.getCenter()[0];
        offset[1] = g2.getCenter()[1] - g1.getCenter()[1];
        return(s1.distanceTo(s2, offset));
    }