Gravity and ground height.

This commit is contained in:
Mal
2020-01-25 13:11:25 +01:00
parent 388799c97e
commit 0cd532f45a
8 changed files with 316 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
import GeometryPoint from "./GeometryPoint.js";
import GeometryStroke from "./GeometryStroke.js";
import GeometryPointCollection from "./GeometryPointCollection.js";
import GeometryLine from "./GeometryLine.js";
export default class GeometryRect
{
@@ -26,12 +25,17 @@ export default class GeometryRect
*/
isContainingPoint(geometryPoint)
{
let containsHorizontally = geometryPoint.x >= this.position.x && geometryPoint.x <= this.position.x + this.width;
let containsVertically = geometryPoint.y >= this.position.y && geometryPoint.y <= this.position.y + this.height;
let containsHorizontally = geometryPoint.x >= this.position.x && geometryPoint.x < this.position.x + this.width;
let containsVertically = geometryPoint.y >= this.position.y && geometryPoint.y < this.position.y + this.height;
return containsHorizontally && containsVertically;
}
isEqual(rect)
{
return rect.x === this.x && rect.y === this.y && rect.width === this.width && rect.height === this.height;
}
hasIntersectionWithRect(rect)
{
return this.getBorderIntersectonsWithRect(rect).getLength() > 0;
@@ -170,8 +174,8 @@ export default class GeometryRect
collection.addGeometryPoint(this.position);
collection.addGeometryPoint(new GeometryPoint(this.position.x + this.width, this.position.y));
collection.addGeometryPoint(new GeometryPoint(this.position.x, this.position.y + this.height));
collection.addGeometryPoint(new GeometryPoint(this.position.x + this.width, this.position.y + this.height));
collection.addGeometryPoint(new GeometryPoint(this.position.x, this.position.y + this.height - 1));
collection.addGeometryPoint(new GeometryPoint(this.position.x + this.width, this.position.y + this.height - 1));
return collection;
}