| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <stdio.h> |
| 19 |
#include <string.h> |
| 20 |
|
| 21 |
#include "table.h" |
| 22 |
#include "cards.h" |
| 23 |
|
| 24 |
static Picture *cards[4][13]; |
| 25 |
static char *suits = "hdcs"; |
| 26 |
static char *values = "a234567890jqk"; |
| 27 |
|
| 28 |
#define W CARD_WIDTH |
| 29 |
#define H CARD_HEIGHT |
| 30 |
#define M CARD_MARGIN |
| 31 |
|
| 32 |
static void |
| 33 |
init() |
| 34 |
{ |
| 35 |
int s, v; |
| 36 |
char name[30]; |
| 37 |
for (s=0; s<4; s++) |
| 38 |
for (v=0; v<13; v++) |
| 39 |
{ |
| 40 |
sprintf(name, "%c%c", values[v], suits[s]); |
| 41 |
cards[s][v] = get_picture(name); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
static void |
| 46 |
redraw() |
| 47 |
{ |
| 48 |
int s, v; |
| 49 |
|
| 50 |
for (s=0; s<4; s++) |
| 51 |
for (v=0; v<13; v++) |
| 52 |
put_picture(cards[s][v], M+v*CARD_FAN_RIGHT, M+s*(M+H), 0, 0, W, H); |
| 53 |
|
| 54 |
for (s=0; s<4; s++) |
| 55 |
for (v=0; v<13; v++) |
| 56 |
put_picture(cards[s][v], 300+s*(W+M), M+v*CARD_FAN_DOWN, 0, 0, W, H); |
| 57 |
|
| 58 |
for (s=0; s<4; s++) |
| 59 |
put_picture(cards[s][0], 300+s*(W+M), M+3*(M+H), 0, 0, W, H); |
| 60 |
} |
| 61 |
|
| 62 |
static FunctionMapping fmap[] = { |
| 63 |
{ "init", (void *)init }, |
| 64 |
{ "redraw", (void *)redraw }, |
| 65 |
{ 0, 0 } |
| 66 |
}; |
| 67 |
|
| 68 |
int |
| 69 |
main(int argc, char **argv) |
| 70 |
{ |
| 71 |
init_ace(argc, argv, fmap); |
| 72 |
init_table(300+4*(W+M), 4*H+5*M); |
| 73 |
table_loop(); |
| 74 |
} |