Mario-Sokoban from the OpenClassroom C Lesson exercice.

main.c 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // main.c
  3. // Mario Sokoban
  4. //
  5. // Created by Benoit Sida on 2014-02-15.
  6. // Copyright (c) 2014 Benoit Sida. All rights reserved.
  7. //
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <SDL2/SDL.h>
  11. #include <SDL2_image/SDL_image.h>
  12. #include "constantes.h"
  13. #include "menu.h"
  14. #include "game.h"
  15. #include "level.h"
  16. #include "editor.h"
  17. #include "difficulty.h"
  18. int main(int argc, const char * argv[])
  19. {
  20. if (SDL_Init(SDL_INIT_VIDEO) == -1) {
  21. printf("Erreur lors de l'initialisation du module SDL. Erreur : %s", SDL_GetError());
  22. exit(EXIT_FAILURE);
  23. }
  24. int choice = 0, diff = 1;
  25. SDL_Window *ecran;
  26. SDL_Surface *screen, *icon;
  27. ecran = SDL_CreateWindow("MARIO SOKOBAN", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, LARGEUR_ECRAN, HAUTEUR_ECRAN, SDL_WINDOW_SHOWN);
  28. screen = SDL_GetWindowSurface(ecran);
  29. icon = IMG_Load("sprites/mario_bas.gif");
  30. SDL_SetWindowIcon(ecran, icon);
  31. while (choice == 0) {
  32. choice = menu(ecran, screen);
  33. switch (choice) {
  34. case 1:
  35. diff = difficulty(ecran, screen);
  36. game(diff, ecran, screen);
  37. choice = 0;
  38. break;
  39. case 2:
  40. editor(ecran, screen);
  41. choice = 0;
  42. break;
  43. }
  44. }
  45. SDL_Quit();
  46. return EXIT_SUCCESS;
  47. }