Advertisement
Guest User

Untitled

a guest
Dec 28th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include "masterinclude.h"
  2.  
  3.  
  4.  
  5. Card* create_card(char* card_normal[],char* card_frame[],char* card_selected[]) {
  6. //allocate space for the "object"
  7.     Card* card = (Card* ) malloc ( sizeof(Card));
  8.     if( card == NULL )
  9.         return NULL;
  10.  
  11.     card->xpm_normal = read_xpm(card_normal, &(card->width), &(card->height));
  12.     card->xpm_frame = read_xpm(card_frame, &(card->width), &(card->height));
  13.     card->xpm_selected = read_xpm(card_selected, &(card->width), &(card->height));
  14.  
  15.     return card;
  16. }
  17.  
  18. void set_card_position(Card *card, int xi, int yi){
  19.     card->x=xi;
  20.     card->y=yi;
  21. }
  22.  
  23.  
  24. void display_xpm(Card *card, int n){
  25.  
  26.     char* map;
  27.     int width=card->width;
  28.     int height=card->height;
  29.     int color=0;
  30.  
  31.     int xi=card->x;
  32.     int yi=card->y;
  33.  
  34.     int yt =yi+height;
  35.  
  36.     switch(n){
  37.     case 1:
  38.         map=card->xpm_normal;
  39.         break;
  40.     case 2:
  41.         map=card->xpm_frame;
  42.         break;
  43.     case 3:
  44.         map=card->xpm_selected;
  45.         break;
  46.     default:
  47.         break;
  48.     }
  49.  
  50.     for(yi; yi < yt;yi++){
  51.         unsigned int x = xi;
  52.         for(x; x < (xi+width);x++){
  53.             vg_set_pixel(x,yi,map[color]);
  54.             color++;
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement