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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
   |  
#include <SDL/SDL.h>
#include <stdio.h>
 
 
typedef struct
{
  int check;
  SDL_Rect pos;
  int clicked;
 
}t_point;
 
int draw_circle(SDL_Surface *screen, t_point *point[6][6])
{
  SDL_Rect pos;
  SDL_Surface *rond;
 
  rond = SDL_LoadBMP("rond.bmp");
 
  if (rond == NULL)
    return (-1);
  for (pos.x=48;pos.x<480;pos.x+=(24+48))
    {
      for (pos.y=48;pos.y<480;pos.y+=72)
        {
          SDL_BlitSurface(rond,NULL,screen,&pos);
        }
    }
  return 0;
}
 
 
SDL_Surface *init_window(int x, int y, char *titre)
{
  SDL_Surface *screen;
 
  if (SDL_Init(SDL_INIT_VIDEO == -1 ))
    return NULL;
  screen = SDL_SetVideoMode(x,y,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
  SDL_WM_SetCaption(titre,NULL);
  return screen;
}
 
int set_background(SDL_Surface *screen,Uint32 color)
{
  SDL_FillRect(screen,NULL,color);
}
 
Uint32 set_color(SDL_Surface *screen, int r, int g, int b)
{
  return (SDL_MapRGB(screen->format,r,g,b));
}
 
 
int main(int argc, char **argv)
{
  SDL_Surface *screen;
  SDL_Event event;
  Uint32 background_color;
  t_point point[6][6];
 
  if (!(screen = init_window(640,480,"Jeux")))
    {
      printf("Erreur lors de l'initialisation");
      return 1;
    }
  background_color = set_color(screen, 255, 255, 255);
 
  set_background(screen,background_color);
  if (draw_circle(screen,&point))
    {
      printf("Erreur lor du chargement de l'image");
      return 1;
    }
  while (event.type != SDL_QUIT)
    {
      SDL_PollEvent(&event);
      SDL_Flip(screen);
    }
 
  SDL_Quit();
  return 0;
} | 
Partager