Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. int main(int argc, char *argv[])
  2. {
  3. int gameloop = 1;
  4. while (gameloop)
  5. {
  6. SDL_Event move;
  7. SDL_PollEvent(&move);
  8. switch(move.type) // Test du type d'évènement
  9. {
  10. case SDL_QUIT: // Si c'est un évènement de type "Quitter"
  11. gameloop = 0;
  12. break;
  13.  
  14. case SDL_KEYDOWN:
  15. switch (move.key.keysym.sym)
  16. {
  17. case SDLK_ESCAPE:
  18. gameloop = 0;
  19. break;
  20. case SDLK_SPACE:
  21. break;
  22. }
  23. }
  24.  
  25. SDL_Surface *ecran = NULL, *dauphin = NULL, *background = NULL;
  26. SDL_Rect position_dauphin, position_background;
  27. position_dauphin.x = 50;
  28. position_dauphin.y = 150;
  29. position_background;
  30. position_background.x = 0;
  31. position_background.y = 0;
  32.  
  33. SDL_Init(SDL_INIT_VIDEO); // Initialisation de la SDL
  34.  
  35. SDL_WM_SetCaption("Blue Ocean ~prototype~", NULL);
  36.  
  37. ecran = SDL_SetVideoMode(800, 600, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); // On tente d'ouvrir une fenêtre
  38. if (ecran == NULL) // Si l'ouverture a échoué, on écrit l'erreur et on arrête
  39. {
  40. fprintf(stderr, "Impossible de charger le mode vidéo : %s\n", SDL_GetError());
  41. exit(EXIT_FAILURE);
  42. }
  43.  
  44. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 30, 145, 183));
  45.  
  46. background = IMG_Load("background.png");
  47. //SDL_SetColorKey(zozor, SDL_SRCCOLORKEY, SDL_MapRGB(dauphin->format, 255, 0, 0));
  48. // Utilisez SDL_SRCCOLORKEY pour activer la transparence, 0 pour la désactiver.
  49. SDL_BlitSurface(background, NULL, ecran, &position_background);
  50.  
  51. dauphin = IMG_Load("dauphin.png");
  52. SDL_SetAlpha(dauphin, SDL_SRCALPHA, 200);
  53. SDL_BlitSurface(dauphin, NULL, ecran, &position_dauphin);
  54.  
  55. SDL_Flip(ecran); /* Mise à jour de l'écran */
  56.  
  57. SDL_FreeSurface(dauphin); /* On libère la surface */
  58. SDL_FreeSurface(background);
  59. SDL_Quit(); // Arrêt de la SDL
  60.  
  61. return EXIT_SUCCESS; // Fermeture du programme
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement