Advertisement
sakiir

Nausée By Sakiir

Dec 27th, 2013
1,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.73 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <SDL/SDL.h>
  4.  
  5. /*
  6. Nausée By Sakiir !
  7. Comment vomir en 30 secondes  
  8. COMPILATION:
  9. gcc -lSDL source.c -o executable
  10.  
  11. */
  12.  
  13.  
  14.  
  15.  
  16. SDL_Surface* s;
  17.  
  18. void initSDL(void);
  19. void attendreTouche(void);
  20. void actualiser(Uint32 c);
  21. Uint32 changercouleur(int couleur);
  22.  
  23. int main(int argc, char** argv)
  24. {
  25.   initSDL();  
  26.   attendreTouche();
  27.   return EXIT_SUCCESS;
  28. }
  29.  
  30. void initSDL(void)
  31. {
  32.   SDL_Init(SDL_INIT_VIDEO);
  33.  
  34.   atexit(SDL_Quit);
  35.   s = SDL_SetVideoMode(1366, 768, 32, SDL_SWSURFACE | SDL_FULLSCREEN); // Mettre Votre Résolution ICI
  36.  
  37.   SDL_WM_SetCaption("Nausée By Sakiir !", NULL);
  38. }
  39.  
  40. void attendreTouche(void)
  41. {
  42.   SDL_Event event;
  43.   int i;
  44.   Uint32 c;
  45.  
  46.   do{
  47.    
  48.     for(i=0;i<=15;i++)
  49.       {
  50.     c = changercouleur(i);
  51.     actualiser(c);
  52.       }
  53.  
  54.     SDL_WaitEvent(&event);
  55.   }
  56.   while (event.type != SDL_QUIT && event.type != SDL_KEYDOWN);
  57. }
  58.  
  59. void actualiser(Uint32 c)
  60. {
  61.   SDL_FillRect(s, &s->clip_rect, c);
  62.   SDL_Flip(s);
  63. }
  64.  
  65. Uint32 changercouleur(int couleur)
  66. {
  67.   Uint32 return_color;
  68.   switch(couleur)
  69.     {
  70.     case 0:
  71.       return_color = SDL_MapRGB(s->format, 0x00, 0x00, 0x00); // NOIR
  72.       break;
  73.     case 1:
  74.       return_color = SDL_MapRGB(s->format, 0x00, 0x00, 0x80); // BLEU_FONCE
  75.       break;
  76.     case 2:
  77.       return_color = SDL_MapRGB(s->format, 0x00, 0x80, 0x00); // VERT_FONCE
  78.       break;
  79.     case 3:
  80.       return_color = SDL_MapRGB(s->format, 0x00, 0x80, 0x80); // CYAN_FONCE
  81.       break;
  82.     case 4:
  83.       return_color = SDL_MapRGB(s->format, 0x80, 0x00, 0x00); // ROUGE_FONCE
  84.       break;
  85.     case 5:
  86.       return_color = SDL_MapRGB(s->format, 0x80, 0x00, 0x80); // MAGENTA_FONCE
  87.       break;
  88.     case 6:
  89.       return_color = SDL_MapRGB(s->format, 0x80, 0x80, 0x00); // OCRE
  90.       break;
  91.     case 7:
  92.       return_color = SDL_MapRGB(s->format, 0xC0, 0xC0, 0xC0); // GRIS_CLAIR
  93.       break;
  94.     case 8:
  95.       return_color = SDL_MapRGB(s->format, 0x80, 0x80, 0x80); // GRIS
  96.       break;
  97.     case 9:
  98.       return_color = SDL_MapRGB(s->format, 0x00, 0x00, 0xFF); // BLEU
  99.       break;
  100.     case 10:
  101.       return_color = SDL_MapRGB(s->format, 0x00, 0xFF, 0x00); // VERT
  102.       break;
  103.     case 11:
  104.       return_color = SDL_MapRGB(s->format, 0x00, 0xFF, 0xFF); // CYAN
  105.       break;
  106.     case 12:
  107.       return_color = SDL_MapRGB(s->format, 0xFF, 0x00, 0x00); // ROUGE
  108.       break;
  109.     case 13:
  110.       return_color = SDL_MapRGB(s->format, 0xFF, 0x00, 0xFF); // MAGENTA
  111.       break;
  112.     case 14:
  113.       return_color = SDL_MapRGB(s->format, 0xFF, 0xFF, 0x00); // JAUNE
  114.       break;
  115.     case 15:
  116.       return_color = SDL_MapRGB(s->format, 0xFF, 0xFF, 0xFF); // BLANC
  117.       break;
  118.     }
  119.  
  120.   return (return_color);
  121.  
  122.  
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement