int w, h, n;
int *tiles;
int completed;
+ int movecount;
};
game_params *default_params(void)
}
assert(!*p);
- state->completed = FALSE;
+ state->completed = state->movecount = 0;
return state;
}
ret->tiles = snewn(state->w * state->h, int);
memcpy(ret->tiles, state->tiles, state->w * state->h * sizeof(int));
ret->completed = state->completed;
+ ret->movecount = state->movecount;
return ret;
}
ret->tiles[C(ret, cx, cy)] = from->tiles[C(from, tx, ty)];
} while (--n > 0);
+ ret->movecount++;
+
/*
* See if the game has been completed.
*/
if (!ret->completed) {
- ret->completed = TRUE;
+ ret->completed = ret->movecount;
for (n = 0; n < ret->n; n++)
if (ret->tiles[n] != n+1)
ret->completed = FALSE;
unclip(fe);
ds->bgcolour = bgcolour;
+
+ /*
+ * Update the status bar.
+ */
+ {
+ char statusbuf[256];
+
+ /*
+ * Don't show the new status until we're also showing the
+ * new _state_ - after the game animation is complete.
+ */
+ if (oldstate)
+ state = oldstate;
+
+ sprintf(statusbuf, "%sMoves: %d",
+ (state->completed ? "COMPLETED! " : ""),
+ (state->completed ? state->completed : state->movecount));
+
+ status_bar(fe, statusbuf);
+ }
}
float game_anim_length(game_state *oldstate, game_state *newstate)
else
return 0.0F;
}
+
+int game_wants_statusbar(void)
+{
+ return TRUE;
+}