Advertisement
Guest User

sdl

a guest
Feb 14th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <SDL/SDL.h>
  4. #include <SDL/SDL_image.h>
  5. #include <SDL/SDL_ttf.h>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.     SDL_Surface *na7la2=NULL,*ecran=NULL;
  10.     SDL_Surface *texte1;
  11.     SDL_Rect position1,position2;
  12.     SDL_Event event;
  13.    
  14.     position1.x = 0;
  15.     position1.y = 0;
  16.    
  17.     position2.x = 0;
  18.     position2.y = 0;
  19.  
  20.     SDL_Init(SDL_INIT_VIDEO);
  21.     TTF_Init();
  22.    
  23.     ecran = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
  24.    
  25.     na7la2=IMG_Load("na7la2.png");
  26.    
  27.     TTF_Font *font;
  28.     font=TTF_OpenFont("ouh.ttf",32);
  29.     SDL_Color fontcouleur={0,0,0};
  30.    
  31.     while (1)
  32.     {
  33.         SDL_BlitSurface(na7la2, NULL, ecran, &position1);
  34.         SDL_WaitEvent(&event);
  35.         if (event.type==SDL_MOUSEBUTTONDOWN)
  36.         {
  37.             if(event.button.button==SDL_BUTTON_RIGHT)
  38.             {
  39.                 texte1=TTF_RenderText_Solid(font,"HELLO , can you hear me ?",fontcouleur);
  40.                 TTF_CloseFont(font);
  41.                 position2.x=0;
  42.                 position2.y=0;
  43.                 SDL_BlitSurface(texte1,NULL,ecran,&position2)
  44.             }
  45.         }
  46.         SDL_Flip(ecran);
  47.     }
  48.    
  49.    
  50.    
  51.    
  52.    
  53.     SDL_FreeSurface(texte1);
  54.     SDL_FreeSurface(na7la2);
  55.     SDL_FreeSurface(ecran);
  56.     TTF_Quit();
  57.     SDL_Quit();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement