X-Git-Url: https://harishankar.org/repos/?p=wordblah.git;a=blobdiff_plain;f=wordblox.h;h=8886fabaa9b388f0543834698dabfb1d4d3270bb;hp=9a5c27ce2c6fc32edc54ba937906cad0e3bfbaae;hb=d27505add68f9df169f2135a416bdf52ce9af8c3;hpb=817fe9c8d7535a465ed42153c550ceef8390ffac diff --git a/wordblox.h b/wordblox.h index 9a5c27c..8886fab 100644 --- a/wordblox.h +++ b/wordblox.h @@ -11,8 +11,9 @@ #include #include "constantstrings.h" -#define MAX_PUZZLE_SIZE 20 +#define MAX_PUZZLE_SIZE 25 #define MAX_CLUE_LENGTH 150 +#define GRID_PIXELS 37 /* Enum to define terminal colours */ enum COLOR { @@ -36,6 +37,12 @@ enum ORIENTATION { DOWN=2 }; +/* for use with the player */ +enum DIRECTION { + DIR_FORWARD = 1, + DIR_BACK = -1 +}; + typedef char String[MAX_CLUE_LENGTH]; /* The main puzzle struct type */ @@ -133,7 +140,7 @@ void export_clues (Puzzle *p, const char *filename) /* Output the grid to image - if answerkey is true export filled grid */ void export_grid_image (Puzzle *p, const char *filename, bool answerkey) { - int img_size = p->grid_size * 40; + int img_size = p->grid_size * GRID_PIXELS; FILE * outfile = fopen (filename, "wb"); if (outfile == NULL) { @@ -154,13 +161,15 @@ void export_grid_image (Puzzle *p, const char *filename, bool answerkey) { /* if it is a block, draw the black square */ if (p->chars[i][j] == '#') - gdImageFilledRectangle (img, j*40, i*40, j*40+40, - i*40+40,black); + gdImageFilledRectangle (img, j*GRID_PIXELS, i*GRID_PIXELS, + j*GRID_PIXELS+GRID_PIXELS, + i*GRID_PIXELS+GRID_PIXELS,black); else { /* draw a regular square */ - gdImageRectangle (img, j*40, i*40, j*40+40, - i*40+40, black); + gdImageRectangle (img, j*GRID_PIXELS, i*GRID_PIXELS, + j*GRID_PIXELS+GRID_PIXELS, + i*GRID_PIXELS+GRID_PIXELS, black); /* print the numers, if it is either start across word or a down word */ @@ -171,22 +180,24 @@ void export_grid_image (Puzzle *p, const char *filename, bool answerkey) { char str[5]; sprintf (str, "%d", p->start_across_word[i][j]); - gdImageString (img, sm_fnt, j*40+2, i*40+2, - (unsigned char *)str, blue); + gdImageString (img, sm_fnt, j*GRID_PIXELS+2, + i*GRID_PIXELS+2, + (unsigned char *)str, blue); } else { char str[5]; sprintf (str, "%d", p->start_down_word[i][j]); - gdImageString (img, sm_fnt, j*40+2, i*40+2, - (unsigned char *)str, blue); + gdImageString (img, sm_fnt, j*GRID_PIXELS+2, + i*GRID_PIXELS+2, + (unsigned char *)str, blue); } } /* if answerkey is true, draw the character in the cell */ if (answerkey) { - gdImageChar (img, lg_fnt, j*40+15, i*40+15, - p->chars[i][j], black); + gdImageChar (img, lg_fnt, j*GRID_PIXELS+15, + i*GRID_PIXELS+10, p->chars[i][j], black); } } }