Debian Codegraph @

tests/test1.c

raw symbols SCIP
1 /* The Ace of Penguins - test1.c
2 Copyright (C) 1998, 2001 DJ Delorie
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
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 }