Couple bounding box fixes

This commit is contained in:
Atlante45 2016-03-02 22:25:30 -08:00
parent 21b3f88dee
commit bef2885957

View file

@ -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;
} }