/* deck_xbm.h include in X11 programs to get bitmaps of cards */ #ifndef DECK_XBM_H #define DECK_XBM_H /*Copyright (C) 1995 Free Software Foundation This header file is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This header file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* names are: c01 for ace of clubs, c02 for duce of clubs, ... c13 for king of clubs d01 for ace of diamonds, ... h01 for ace of hearts, ... s01 for ace of spades, s02 for duce of spades, ... s13 for king of spades joker is joker back is a card back, back1, more may appear later, e.g. back2 ... cards are width=71 pixels, height=96 pixels which includes the border eight pixels between looks reasonable as in solitaire piles 20 top pixels exposed looks reasonable for vertical stacking 18 side pixels exposed looks reasonable for horizontal stacking (add more space for widget borders when using tool kits, e.g. ToggleButtons work nice with "back1" and some card toggling) diamonds and hearts may have foreground red on a color display. clubs and spades usually have a foreground of black ;-) reversing black and white really looks bad! num_cards is present number of cards, including joker and backs. card_name[0] ... card_name[num_cards-1] are the names. The first 52 are a standard poker deck. the function shuffle() builds the deck[i] i=0 to 51 with a random permutation of 0 to 51. Just deal using card_name[deck[0]], ... card_name[deck[51]], or just call my_card = deal_next(). in case you did not notice card_name[i][0] gives the suit 'c','d','h','s' and atoi(strncpy(junk,card_name[i]+1,2)) gives 1 for ace, ... 13 for king. Just call card_suit(my_card) for suit as character (upper case) or card_int(my_card) for integer value, used to check size or get points or xx = card_sym(card_int(my_card)) to get printable value. "A ", "10", ... */ #define card_width 71 #define card_height 96 #define num_cards 55 void shuffle(void); /* shuffles the deck */ char *deal_next(void); /* returns a card name */ char card_suit(char *card_name); /* D, C, H, S */ int card_int(char *card_name); /* 1=A, 2=duce, ... 13=K */ char *card_sym(int card_int); /* "A ", "2 ", ... "10", ... "K " */ char *card_xbm(char *card_names); /* address of xbm_bits */ double my_random (double *Gen); void reset_r(double *Gen); /* the names by which cards are known, used to look up bit map data */ extern char *card_name[num_cards]; /* c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, c11, c12, c13, d01, d02, d03, d04, d05, d06, d07, d08, d09, d10, d11, d12, d13, h01, h02, h03, h04, h05, h06, h07, h08, h09, h10, h11, h12, h13, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, joker, back, back1 */ /* initial deck, random permutation caused by shuffel() */ extern int deck[52]; /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 */ /* BE SURE TO LINK WITH deck_xbm.o it has the bitmaps and code */ #endif