Work on puzzle grid in player
[wordblah.git] / wordblox.h
index 9a5c27c..8886fab 100644 (file)
@@ -11,8 +11,9 @@
 #include <zlib.h>
 #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);
                                }
                        }
                }