X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=kub.c;h=c15d850bc7c5c014e5b480364e4068f8c5ab3b79;hb=57cab1ca36a6f7fc4bc46928efbe6cc480d34866;hp=0f195740f64b4f0b156412961a312157ee3e3349;hpb=d5fffb73ddb4b6f189d333daa9c1d65f41b6fc6a;p=kub diff --git a/kub.c b/kub.c index 0f19574..c15d850 100644 --- a/kub.c +++ b/kub.c @@ -5,6 +5,42 @@ #include #include +/* + * TILE_NUMBER_X_OFFSET = 3 + * // + * || TILE_NUMBER_WIDTH = 34 + * ||/ / + * || | TILE_WIDTH = 40 + * || | / + * | | + * +-----+ - TILE_NUMBER_Y_OFFSET = 3 - + * |+---+| - | + * || || | + * || || TILE_NUMBER_HEIGHT = 24 | + * |+---+| - | + * | _ | _ |-TILE_HEIGHT = 50 + * | / \ | | + * || || TILE_SUN_HEIGHT = 20 | + * | \_/ | _ | + * | | TILE_SUN_Y_OFFSET = 3 | + * +-----+ - - + * || | TILE_SUN_WIDTH = 20 + * || + * || TILE_SUN_X_OFFSET = 10 + */ +#define TILE_WIDTH 40 +#define TILE_HEIGHT 50 + +#define TILE_NUMBER_X_OFFSET 3 +#define TILE_NUMBER_Y_OFFSET 3 +#define TILE_NUMBER_WIDTH 34 +#define TILE_NUMBER_HEIGHT 24 + +#define TILE_SUN_X_OFFSET 10 +#define TILE_SUN_Y_OFFSET 3 +#define TILE_SUN_WIDTH 20 +#define TILE_SUN_HEIGHT 20 + #define FATAL_ERROR(msg) \ do { fprintf (stderr, "Error: %s\n", msg); exit (1); } while (0) @@ -15,6 +51,8 @@ typedef enum {BLACK, BLUE, RED, YELLOW} color_t; typedef struct tile { color_t color; int number; + int x; + int y; } tile_t; #define DECK_MAX_TILES 104 @@ -59,6 +97,8 @@ tile_init (tile_t *tile, color_t color, int number) { tile->color = color; tile->number = number; + tile->x = 0; + tile->y = 0; } static void tile_print(tile_t tile) @@ -66,7 +106,7 @@ static void tile_print(tile_t tile) printf("%6s %2d\n", colors[tile.color], tile.number + 1); } -static void tile_draw(game_t *game, tile_t *tile, cairo_t *cr, int x, int y) +static void tile_draw(game_t *game, tile_t *tile, cairo_t *cr) { char number_string[3]; int len; @@ -76,7 +116,7 @@ static void tile_draw(game_t *game, tile_t *tile, cairo_t *cr, int x, int y) FATAL_ERROR ("snprintf failed"); cairo_save(cr); - cairo_translate(cr, x, y); + cairo_translate(cr, tile->x, tile->y); rsvg_handle_render_cairo (game->blanktile, cr); if (tile->color == BLACK) @@ -325,8 +365,7 @@ static void deck_draw(game_t *game, cairo_t *cr) { for (j = 0; j < 13; ++j) { - tile_draw(game, &game->deck.tiles[j + (i * 13)], - cr, 45 * j, 55 * i); + tile_draw(game, &game->deck.tiles[j + (i * 13)], cr); } } }