Update updateBillboard argument

This commit is contained in:
Ryan Huffman 2015-11-09 10:59:31 -08:00
parent dad3ccb238
commit 661b2180f5

View file

@ -347,21 +347,21 @@ function Baseball(position, velocity, ballScale) {
} }
} }
// Update the stadium billboard with the current distance and update the high score // Update the stadium billboard with the current distance or a text message and update the high score
// if it has been beaten. // if it has been beaten.
function updateBillboard(distance) { function updateBillboard(distanceOrMessage) {
Entities.editEntity(DISTANCE_BILLBOARD_ENTITY_ID, { Entities.editEntity(DISTANCE_BILLBOARD_ENTITY_ID, {
text: distance, text: distanceOrMessage,
}); });
// If a number was passed in, let's see if it is larger than the current high score // If a number was passed in, let's see if it is larger than the current high score
// and update it if so. // and update it if so.
if (!isNaN(distance)) { if (!isNaN(distanceOrMessage)) {
var properties = Entities.getEntityProperties(HIGH_SCORE_BILLBOARD_ENTITY_ID, ["text"]); var properties = Entities.getEntityProperties(HIGH_SCORE_BILLBOARD_ENTITY_ID, ["text"]);
var bestDistance = parseInt(properties.text); var bestDistance = parseInt(properties.text);
if (distance >= bestDistance) { if (distanceOrMessage >= bestDistance) {
Entities.editEntity(HIGH_SCORE_BILLBOARD_ENTITY_ID, { Entities.editEntity(HIGH_SCORE_BILLBOARD_ENTITY_ID, {
text: distance, text: distanceOrMessage,
}); });
return true; return true;
} }