[erm, resend with patch attached]
On Wed, Sep 09, 2009 at 03:31:20PM +0800, Paul Wise wrote:
> I think the game needs a "Skill" option in the menu with about
> 5-10 different options that would adjust the speed of the ball
> advancement, the probability of special items, the speed of balls
> ...
The attached patch is just a prototype, changing magic numbers in
to compile-time #defs in game.h. I'm not picking up the task of
properly fixing this bug yet, but it has my suggestions on things
to adjust.
+/* Number of adjacent balls of the same color to make them explode. */
+#define NUMBER_MATCHING_TO_ELIMINATE 3
+
+/* Each level defines how many colors are used for that level; this constant is
+ * then added to adjust the difficulty (negative makes it easier).
+ * (There will always be a minimum of 3 colors, and max of NBALLCOLORS).
+ * */
+#define DELTA_BALLCOLORS (-2)
(It also deletes a duplicate definition of NBALLCOLORS, which I
tried adjusting before writing the DELTA_BALLCOLORS changes).
Steve
diff --git a/src/ballpath.cpp b/src/ballpath.cpp
index 1e2f695..32ec65c 100644
--- a/src/ballpath.cpp
+++ b/src/ballpath.cpp
@@ -578,28 +578,36 @@ void BallPath::Eliminate()
(*mixer)->EnqueueSample(sfx_combo, sfxVol);
}
- if (balls.size() < 3)
+ if (balls.size() < NUMBER_MATCHING_TO_ELIMINATE)
return;
- for (uint b = 0; b < balls.size() - 2; ++b)
+ for (uint b = 0; b <= balls.size() - NUMBER_MATCHING_TO_ELIMINATE; ++b)
{
int col = balls[b].col;
+ bool matching = true;
- if ((balls[b + 1].col == col)
- && (balls[b + 2].col == col)
- && (balls[b].size == stepsPerBall)
- && (balls[b + 1].size == stepsPerBall)
- && (balls[b + 2].size == stepsPerBall)
- && (balls[b + 2].pos - balls[b + 1].pos < (double)STEPSPERBALL * 1.01)
- && (balls[b + 1].pos - balls[b].pos < (double)STEPSPERBALL * 1.01))
- {
- balls[b].elim = true;
- balls[b + 1].elim = true;
- balls[b + 2].elim = true;
-
- balls[b].explode = true;
- balls[b + 1].explode = true;
- balls[b + 2].explode = true;
+ if (balls[b].size != stepsPerBall)
+ {
+ matching = false;
+ }
+
+ for (int i = 1; i < NUMBER_MATCHING_TO_ELIMINATE; i++)
+ {
+ if ((balls[b + i].col != col)
+ || (balls[b + i].size != stepsPerBall)
+ || (balls[b + i].pos - balls[b + i - 1].pos > (double)STEPSPERBALL * 1.01))
+ {
+ matching = false;
+ }
+ }
+
+ if (matching)
+ {
+ for (int i = 0; i < NUMBER_MATCHING_TO_ELIMINATE; i++)
+ {
+ balls[b + i].elim = true;
+ balls[b + i].explode = true;
+ }
}
}
diff --git a/src/game.cpp b/src/game.cpp
index 156f159..5b77657 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -111,7 +111,7 @@ Game::Game(Scenes::Settings *settings, SDL_Surface *surf, Level &level, GLuint *
{
ballPaths[b] = new BallPath(level.paths[b + 1], ballText, &mix, false);
ballPaths[b]->state.ballsToDraw = level.ballsToDraw;
- ballPaths[b]->state.colors = level.colors;
+ ballPaths[b]->state.colors = std::max(std::min(level.colors + DELTA_BALLCOLORS, NBALLCOLORS), 3);
ballPaths[b]->state.feedRate = 1;
ballPaths[b]->state.ballsFromStart = level.ballsFromStart;
}
@@ -375,7 +375,7 @@ void Game::Logic(ulong frame)
int extraCol = -1;
for (int f = 0; f < NBALLCOLORS; f++)
{
- if ((cols[f] > 0) && (cols[f] < 3))
+ if ((cols[f] > 0) && (cols[f] < NUMBER_MATCHING_TO_ELIMINATE))
extraCol = f;
}
diff --git a/src/game.h b/src/game.h
index 51857de..0f46599 100644
--- a/src/game.h
+++ b/src/game.h
@@ -29,7 +29,14 @@
using namespace Scenes;
-#define NBALLCOLORS 8
+/* Number of adjacent balls of the same color to make them explode. */
+#define NUMBER_MATCHING_TO_ELIMINATE 3
+
+/* Each level defines how many colors are used for that level; this constant is
+ * then added to adjust the difficulty (negative makes it easier).
+ * (There will always be a minimum of 3 colors, and max of NBALLCOLORS).
+ * */
+#define DELTA_BALLCOLORS (-2)
extern Sample *sfx_pull;
extern Sample *sfx_push;