Advertisement
zeeph

Untitled

Apr 4th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <SDL/SDL.h>
  2. #include "helpers.h"
  3. #include <time.h>
  4.  
  5.  
  6. void pause(SDL_Rect pos, SDL_Surface* ecran)
  7. {
  8. int continuer = 1;
  9.  
  10. SDL_Event event;
  11. while (continuer)
  12. {
  13. SDL_WaitEvent(&event);
  14. switch(event.type)
  15. {
  16. case SDL_QUIT:
  17. continuer = 0;
  18. default:
  19. pos.y += 10;
  20. generateSprite(pos, randomSprite, ecran);
  21. if(pos.y < 400)
  22. {
  23. pos.y = 0;
  24. randomSprite() = generateSprite();
  25. srand(time(NULL));
  26. int absrand = rand()%550;
  27. pos.x = absrand;
  28. }
  29. }
  30. }
  31. }
  32.  
  33. int randomSprite()
  34. {
  35. srand(time(NULL));
  36. int rtn = rand()%5;
  37. return rtn;
  38. }
  39.  
  40.  
  41. void generateSprite(SDL_Rect pos1, int spriteType, SDL_Surface* ecran)
  42. {
  43. SDL_Surface *logo_Evolukid1 = NULL;
  44. SDL_Surface *logo_Evolukid2 = NULL;
  45. SDL_Surface *logo_Evolukid3 = NULL;
  46. SDL_Surface *logo_Evolukid4 = NULL;
  47.  
  48. logo_Evolukid1 = SDL_LoadBMP("imageCool.bmp");
  49. logo_Evolukid2 = SDL_LoadBMP("imageCool.bmp");
  50. logo_Evolukid3 = SDL_LoadBMP("imageCool.bmp");
  51. logo_Evolukid4 = SDL_LoadBMP("imageCool.bmp");
  52.  
  53. SDL_Rect pos2;
  54. SDL_Rect pos3;
  55. SDL_Rect pos4;
  56.  
  57. switch(spriteType)
  58. {
  59. case LD:
  60. // Dessine une L Droit
  61. pos2.x = pos1.x;
  62. pos2.y = pos1.y + 60;
  63. pos3.x = pos1.x;
  64. pos3.y = pos1.y + 120;
  65. pos4.x = pos1.x + 60;
  66. pos4.y = pos1.y + 120;
  67. break;
  68. case BARRE:
  69. // Dessine une barre
  70. pos2.x = pos1.x;
  71. pos2.y = pos1.y + 60;
  72. pos3.x = pos1.x;
  73. pos3.y = pos1.y + 120;
  74. pos4.x = pos1.x;
  75. pos4.y = pos1.y + 120;
  76. break;
  77. case TD:
  78. // Dessine un T droit
  79. pos2.x = pos1.x + 60;
  80. pos2.y = pos1.y;
  81. pos3.x = pos1.x + 120;
  82. pos3.y = pos1.y;
  83. pos4.x = pos1.x + 60;
  84. pos4.y = pos1.y + 60;
  85. break;
  86. case CARRE:
  87. // Dessine un carre
  88. pos2.x = pos1.x;
  89. pos2.y = pos1.y + 60;
  90. pos3.x = pos1.x;
  91. pos3.y = pos1.y + 120;
  92. pos4.x = pos1.x + 60;
  93. pos4.y = pos1.y + 120;
  94. break;
  95. case LI:
  96. // Dessine un L inverse
  97. pos2.x = pos1.x;
  98. pos2.y = pos1.y + 60;
  99. pos3.x = pos1.x;
  100. pos3.y = pos1.y + 120;
  101. pos4.x = pos1.x + 60;
  102. pos4.y = pos1.y + 120;
  103. break;
  104. default:
  105. break;
  106. }
  107. SDL_BlitSurface(logo_Evolukid1, NULL, ecran, &pos1);
  108. SDL_BlitSurface(logo_Evolukid2, NULL, ecran, &pos2);
  109. SDL_BlitSurface(logo_Evolukid3, NULL, ecran, &pos3);
  110. SDL_BlitSurface(logo_Evolukid4, NULL, ecran, &pos4);
  111. SDL_Flip(ecran);
  112. SDL_Delay(100);
  113. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
  114. SDL_Flip(ecran);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement