#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 {
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 */
/* 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)
{
{
/* 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 */
{
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);
}
}
}