diff --git a/src/org/frice/obj/Objects.kt b/src/org/frice/obj/Objects.kt index dad15b9..f9057cf 100644 --- a/src/org/frice/obj/Objects.kt +++ b/src/org/frice/obj/Objects.kt @@ -30,13 +30,10 @@ interface AbstractObject { * @author ice1000 * @since v0.4 */ -interface FContainer { +interface FContainer : FShapeQuad { - var x: Double - var y: Double - - val width: Double - val height: Double + override var x: Double + override var y: Double fun containsPoint(px: Int, py: Int) = px >= x && px <= x + width && py >= y && py <= y + height diff --git a/src/org/frice/obj/sub/ImageObject.kt b/src/org/frice/obj/sub/ImageObject.kt index 27fcd1e..364abb8 100644 --- a/src/org/frice/obj/sub/ImageObject.kt +++ b/src/org/frice/obj/sub/ImageObject.kt @@ -21,7 +21,7 @@ constructor( var res: ImageResource, override var x: Double = 0.0, override var y: Double = 0.0, - id: Int = -1) : FShapeQuad, FObject(), FObject.ImageOwner { + id: Int = -1) : FObject(), FObject.ImageOwner { constructor(res: FriceImage, x: Double, y: Double) : this(create(res), x, y, -1) init { diff --git a/src/org/frice/utils/QuadTree.kt b/src/org/frice/utils/QuadTree.kt index 3ebbdef..6b3ee10 100644 --- a/src/org/frice/utils/QuadTree.kt +++ b/src/org/frice/utils/QuadTree.kt @@ -2,6 +2,7 @@ package org.frice.utils import org.frice.obj.PhysicalObject import org.frice.utils.shape.FQuad +import org.frice.utils.shape.FShapeQuad import java.util.* /** @@ -26,6 +27,13 @@ class QuadTree(private var level: Int, private var bounds: FQuad) { for (i in nodes.indices) nodes[i] = null } + private fun isInner(ob: PhysicalObject, quad: FShapeQuad): Boolean { + return ob.x >= quad.x + && ob.x + ob.width <= quad.x + quad.width + && ob.y >= quad.y + && ob.y + ob.height <= quad.y + quad.height + } + private fun split() { // width & height val subWidth = bounds.width / 2 diff --git a/src/org/frice/utils/media/AudioPlayer.kt b/src/org/frice/utils/media/AudioPlayer.kt index aa7e9bf..69ff3b5 100644 --- a/src/org/frice/utils/media/AudioPlayer.kt +++ b/src/org/frice/utils/media/AudioPlayer.kt @@ -31,7 +31,7 @@ class AudioPlayer internal constructor(file: File) : Thread() { /** * @author ice1000 * @since v1.7.6 - * @see AudioPlayer + * @see org.frice.utils.media.AudioPlayer */ class AudioPlayerRunnable(file: File) : Runnable { private var audioInputStream: AudioInputStream diff --git a/src/org/frice/utils/shape/Quads.kt b/src/org/frice/utils/shape/Quads.kt index d13e090..17a239e 100644 --- a/src/org/frice/utils/shape/Quads.kt +++ b/src/org/frice/utils/shape/Quads.kt @@ -1,6 +1,9 @@ package org.frice.utils.shape /** + * It's just an abstract representation of an object + * with x, y, width and height. + * * @author ice1000 * @since v1.6.7 * @see org.frice.utils.shape.FQuad diff --git a/src/org/frice/utils/shape/Shapes.kt b/src/org/frice/utils/shape/Shapes.kt index 5dba45b..87821b3 100644 --- a/src/org/frice/utils/shape/Shapes.kt +++ b/src/org/frice/utils/shape/Shapes.kt @@ -2,19 +2,12 @@ package org.frice.utils.shape import java.awt.geom.Rectangle2D -/** - * Created by ice1000 on 2016/8/14. - * @author ice1000 - * @since v0.1.1 - */ -interface FShape - -interface FShapeInt : FShape { +interface FShapeInt { var width: Int var height: Int } -interface FShapeDouble : FShape { +interface FShapeDouble { var width: Double var height: Double } @@ -42,7 +35,7 @@ open class FOval(rh: Double, rv: Double) : FShapeInt { * @author ice1000 * @since v0.3 */ -data class FPoint(var x: Int, var y: Int) : FShape +data class FPoint(var x: Int, var y: Int) /** * Created by ice1000 on 2016/8/14.