Commit 9c54b987 authored by Terence Martin's avatar Terence Martin

Update ball drop finished event handler

The ballDropComplete() handler now takes a boolean flag that indicates
if this ball drop was finalized as part of a regular ball drop (false)
or a final ball drop (true).

This allows us to apply score to the ball when it stops, if we need
to.
parent 91733a2c
......@@ -4504,7 +4504,7 @@ var nurdz;
// If there is a listener, tell it that this ball has stopped
// moving now.
if (this._listener != null)
this._listener.ballDropComplete(this._lastDroppedBall);
this._listener.ballDropComplete(this._lastDroppedBall, this._droppingFinalBall);
// Done with the value now.
this._lastDroppedBall = null;
}
......@@ -5093,9 +5093,15 @@ var nurdz;
* This is triggered for any ball drop; human or computer, during the
* regular game or as the final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* The owner of the ball can be determined from the ball entity itself
* while isFinal tells you if the ball finished dropping as part of a
* regular or final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* @param {boolean} isFInal true if this ball was part of a final ball
* drop
*/
GameScene.prototype.ballDropComplete = function (ball) {
GameScene.prototype.ballDropComplete = function (ball, isFinal) {
// Did the ball reach the goal? This is good enough for testing.
if (ball.mapPosition.y == game.MAZE_HEIGHT - 2)
console.log("GOOOOOAL!");
......
......@@ -34,9 +34,15 @@ module nurdz.game
* This is triggered for any ball drop; human or computer, during the
* regular game or as the final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* The owner of the ball can be determined from the ball entity itself
* while isFinal tells you if the ball finished dropping as part of a
* regular or final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* @param {boolean} isFInal true if this ball was part of a final ball
* drop
*/
ballDropComplete (ball : Ball) : void;
ballDropComplete (ball : Ball, isFinal : boolean) : void;
/**
* A ball that is blocked has been told that it's being removed from
......@@ -1067,7 +1073,8 @@ module nurdz.game
// If there is a listener, tell it that this ball has stopped
// moving now.
if (this._listener != null)
this._listener.ballDropComplete (this._lastDroppedBall);
this._listener.ballDropComplete (this._lastDroppedBall,
this._droppingFinalBall);
// Done with the value now.
this._lastDroppedBall = null;
......
......@@ -519,11 +519,16 @@ module nurdz.game
* This is triggered for any ball drop; human or computer, during the
* regular game or as the final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* The owner of the ball can be determined from the ball entity itself
* while isFinal tells you if the ball finished dropping as part of a
* regular or final ball drop.
*
* @param {Ball} ball the ball that stopped dropping
* @param {boolean} isFInal true if this ball was part of a final ball
* drop
*/
ballDropComplete (ball : Ball) : void
ballDropComplete (ball : Ball, isFinal : boolean) : void
{
// Did the ball reach the goal? This is good enough for testing.
if (ball.mapPosition.y == MAZE_HEIGHT - 2)
console.log ("GOOOOOAL!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment