commit f76f7745fd9b85a1cfb581e83ed21ce78392250f
Author: rani <clagv.randomgames@gmail.com>
Date: Sat Aug 05 13:58:21 2023 +0000
diff --git a/bejeweled/README.md b/bejeweled/README.md
index 2e412d0..e92d5b1 100644
--- a/bejeweled/README.md
+++ b/bejeweled/README.md
@@ -103 +104 @@ Tile match game. Click on a tile to select it, click on another tile directly ad
* `SHIFT_DELAY`: The delay between shifts of tiles above each other when a match is made
* `MATCH_DELAY`: The delay after a successful match
* `BAD_MATCH_DELAY`: The delay after a non successful match
+* `GRID`: Either `true` or `false`, whether or not to show the grid outline
diff --git a/bejeweled/bejeweled.c b/bejeweled/bejeweled.c
index 7e00055..b62bb8b 100644
--- a/bejeweled/bejeweled.c
+++ b/bejeweled/bejeweled.c
@@ -286 +2810 @@
#define BAD_MATCH_DELAY 750
#endif /* BAD_MATCH_DELAY */
+#ifndef GRID
+#define GRID true
+#endif /* GRID */
+
#define SQUARE_C '#'
#define CIRCLE_C 'O'
#define TRIANGLE_C 'A'
@@ -11711 +12114 @@ void newgem(struct coord c) {
void display(void) {
erase();
- for (int x = 0; x < X; x++) addstr("+ - ");
- addstr("+\n");
+ if (GRID) {
+ for (int x = 0; x < X; x++) addstr("+ - ");
+ addstr("+\n");
+ } else addch('\n');
for (int y = 0; y < Y; y++) {
for (int x = 0; x < X; x++) {
- addstr("| ");
+ if (GRID) addstr("| ");
+ else addstr(" ");
int cp = GETCOLOR(GETGEM(grid[x][y]));
bool reverse = false;
if (HIGHLIGHT) reverse = true;;
@@ -1339 +14011 @@ void display(void) {
attroff(cp);
addch(' ');
}
- addstr("|\n");
- for (int x = 0; x < X; x++) addstr("+ - ");
- addstr("+\n");
+ if (GRID) {
+ addstr("|\n");
+ for (int x = 0; x < X; x++) addstr("+ - ");
+ addstr("+\n");
+ } else addstr("\n\n");
}
attron(A_REVERSE);
@@ -29427 +30335 @@ int main(void) {
struct coord hc[X];
int h = checkhoriz(x, y, hc);
+ struct coord rc[Y + X];
+ int r = 0;
if (v >= 3) {
- first = invc;
sort(vc, v);
- makepop(vc, v);
- display();
- napms(MATCH_DELAY);
- shift(vc, v);
+ while (v--) {
+ rc[r] = vc[r];
+ r++;
+ }
+ }
- score += 1000;
- v -= 3;
- score += 2000*v;
- } else if (h >= 3) {
+ if (h >= 3) {
+ int i = 0;
+ while (h--) {
+ rc[r] = hc[i];
+ i++;
+ r++;
+ }
+ }
+
+ if (r >= 3) {
first = invc;
- makepop(hc, h);
+ makepop(rc, r);
display();
napms(MATCH_DELAY);
- shift(hc, h);
+ shift(rc, r);
score += 1000;
- h -= 3;
- score += 2000*h;
+ r -= 3;
+ score += 2000*r*r;
} else {
// no matches
struct coord c = first;
@@ -34129 +35835 @@ int main(void) {
int v = checkvert(nx, ny, vc);
struct coord hc[X];
int h = checkhoriz(nx, ny, hc);
+ struct coord rc[Y + X];
+ int r = 0;
if (v >= 3) {
- nc += v;
-
sort(vc, v);
- makepop(vc, v);
- display();
- napms(750);
- shift(vc, v);
+ while (v--) {
+ rc[r] = vc[r];
+ r++;
+ }
+ }
- score += 1000;
- v -= 3;
- score += 2000*v;
- } else if (h >= 3) {
- nc += h;
+ if (h >= 3) {
+ int i = 0;
+ while (h--) {
+ rc[r] = hc[i];
+ i++;
+ r++;
+ }
+ }
- makepop(hc, h);
+ if (r >= 3) {
+ first = invc;
+ makepop(rc, r);
display();
- napms(750);
- shift(hc, h);
+ napms(MATCH_DELAY);
+ shift(rc, r);
score += 1000;
- h -= 3;
- score += 2000*h;
+ r -= 3;
+ score += 2000*r*r;
}
}
}