...
 
Commits (7)
  • Terence Martin's avatar
    Tweak black hole generation · 7d2bfa79
    Terence Martin authored
    We now generate the black holes into a narrower band in the maze
    content area; they will not populate near the top or bottom of the
    grid, and they won't spawn next to the walls.
    
    Additionally, the range between them has been extended a tile and we
    ensure that there is only ever a single teleport per column at most,
    to maximize the chaos of the ball jumping around in the maze.
    7d2bfa79
  • Terence Martin's avatar
    Change arrow generation to be per column · 056d8c83
    Terence Martin authored
    We now generate arrows by column instead of by row. This makes for a
    more pleasing layout, as it ensures that the arrow are a bit less
    clumpy and that there are no paths through the maze that don't take a
    weird circuitious route.
    056d8c83
  • Terence Martin's avatar
    Change gray brick generation to be per column · be1798e4
    Terence Martin authored
    This now works the same as the arrow generation, although we now
    possibly have no gray bricks in a column, where an arrow always has
    at least one.
    be1798e4
  • Terence Martin's avatar
    Change bonus brick generation to be per column · a51f866a
    Terence Martin authored
    This works the same as the gray brick code. In fact, so similar that
    it seems like I should actually make that one method that does both.
    a51f866a
  • Terence Martin's avatar
    Cleanup; remove redundant code · 517aaf44
    Terence Martin authored
    This removes some methods that used to be used to generate randomly
    selected columns and rows. Now each method does this on their own,
    so that they can customize the range if they want to.
    517aaf44
  • Terence Martin's avatar
    Fix blocked player playing ball bug · ef9e9917
    Terence Martin authored
    This is the bug where the player can try to push the ball while its
    blocked and it still works. This would get things all out of sync
    and mess everything up.
    ef9e9917
  • Terence Martin's avatar
    Clear unplayed balls at the appropriate time · 770002c1
    Terence Martin authored
    This ensures that if any balls are unplayed for either player (due to
    being blocked), they are visually removed from the screen while all of
    the blocked balls are being removed, so that they don't remain just
    dangling there at the end of the run.
    770002c1
This diff is collapsed.
......@@ -351,6 +351,29 @@ module nurdz.game
for (let i = 0 ; i < MAZE_WIDTH * MAZE_HEIGHT ; i++)
this._contents[i] = null;
// Clear the unplayed ball arrays as well. No hiding in this case
// because this gets called during initialization, where there might
// not be any valid arrays yet.
this.clearUnplayedBalls (false);
}
/**
* Clear the unplayed balls from the data storage for them; this affects
* both players.
*
* If the hide parameter is true, this will first tell any balls that
* still exist as an unplayed ball to hide itself before the array is
* cleaned up, so that the balls are also visually removed.
*/
clearUnplayedBalls (hide : boolean) : void
{
// SHould we hide any?
if (hide)
{
this.hideBallsInArray (this._playerBalls);
this.hideBallsInArray (this._computerBalls);
}
// Ensure that the ball arrays for both players are fully empty.
for (let i = 0 ; i < MAZE_WIDTH - 2 ; i++)
{
......@@ -359,6 +382,7 @@ module nurdz.game
}
}
/**
* Given an array of balls which is the full size of the content area of
* the maze (less the walls on either sides), check and see if any of
......
This diff is collapsed.
......@@ -463,7 +463,8 @@ module nurdz.game
* column in the maze, if possible.
*
* The ball can only be pushed if the cell in the maze at that position
* is not empty, is a ball, and there is not already a ball dropping.
* is not empty, is a ball, is not immediately blocked from moving, and
* there is not already a ball dropping.
*
* The return value tells you if the drop started or not.
*
......@@ -475,12 +476,18 @@ module nurdz.game
pushBall (column : number) : boolean
{
// Try to get the entity in the first row of the given column. If
// it exists and it is a ball, push it.
let entity = this._contents.getCellAt (column, 0);
// it exists and it is a ball, we might want to push it.
let entity = <Ball> this._contents.getCellAt (column, 0);
if (entity != null && entity.name == "ball" && this._droppingBall == null)
{
// If the cell below the ball is blocked, this ball cannot be
// pushed, in which case we should leave without pushing the
// ball.
if (this._contents.getBlockingCellAt (column, 1, false) != null)
return false;
// Drop it and leave.
this.dropBall (<Ball> entity, NORMAL_DROP_SPEED, false);
this.dropBall (entity, NORMAL_DROP_SPEED, false);
return true;
}
......@@ -1209,10 +1216,6 @@ module nurdz.game
this._bonusBricks.killALl ();
this._balls.killALl ();
this._contents.clearMarkers ();
// Make sure that our black hole entity doesn't know about any
// destinations from a prior maze (if any).
this._blackHole.clearDestinations ();
}
/**
......@@ -1229,7 +1232,7 @@ module nurdz.game
this._droppingFinalBall = false;
// Now generate the contents of the maze.
this._generator.generate ();
this._generator.generate (true);
// Reset the scores
resetScores ();
......
......@@ -646,6 +646,13 @@ module nurdz.game
this._computer.ai_startingTurn ();
break;
// When we are entering the state for removing all blocked
// balls, make sure that the maze contents discards all unplayed
// balls so that they visually leave the screen.
case GameState.REMOVE_BLOCKED_BALLS:
this._maze.contents.clearUnplayedBalls (true);
break;
// When we enter the final ball drop, hide the player and
// computer characters.
case GameState.FINAL_BALL_DROP:
......