mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 12:12:32 +02:00
Couple bounding box fixes
This commit is contained in:
parent
21b3f88dee
commit
bef2885957
1 changed files with 8 additions and 6 deletions
|
@ -39,8 +39,8 @@
|
||||||
this.position = function() {
|
this.position = function() {
|
||||||
return { x: xPosition, y: yPosition };
|
return { x: xPosition, y: yPosition };
|
||||||
}
|
}
|
||||||
this.size = function() {
|
this.dimensions = function() {
|
||||||
return DIMENSION;
|
return dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = entityManager.add({
|
var id = entityManager.add({
|
||||||
|
@ -77,7 +77,9 @@
|
||||||
dimensions.z = naturalDimensions.z / max * dimensions.z;
|
dimensions.z = naturalDimensions.z / max * dimensions.z;
|
||||||
dimensionsSet = true;
|
dimensionsSet = true;
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
|
dimensions = Entities.getEntityProperties(id, ["dimensions"]).dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
yPosition += deltaTime * (yVelocity + deltaTime * yAcceleration / 2.0);
|
yPosition += deltaTime * (yVelocity + deltaTime * yAcceleration / 2.0);
|
||||||
yVelocity += deltaTime * yAcceleration;
|
yVelocity += deltaTime * yAcceleration;
|
||||||
|
@ -124,9 +126,9 @@
|
||||||
}
|
}
|
||||||
this.isColliding = function(bird) {
|
this.isColliding = function(bird) {
|
||||||
var deltaX = Math.abs(this.position() - bird.position().x);
|
var deltaX = Math.abs(this.position() - bird.position().x);
|
||||||
if (deltaX < (bird.size() + width) / 2.0) {
|
if (deltaX < (bird.dimensions().z + width) / 2.0) {
|
||||||
var upDistance = (yPosition - upHeight) - (bird.position().y + bird.size());
|
var upDistance = (yPosition - upHeight) - (bird.position().y + bird.dimensions().y);
|
||||||
var downDistance = (bird.position().y - bird.size()) - height;
|
var downDistance = (bird.position().y - bird.dimensions().y) - height;
|
||||||
if (upDistance <= 0 || downDistance <= 0) {
|
if (upDistance <= 0 || downDistance <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue