Guest User

Untitled

a guest
Apr 13th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. // Snooping through the files now aren't you?
  2.  
  3. // Compile With: g++ main.cpp loadImage.h -lSDL2 -lSDL2_image -o "Butter Game"
  4.  
  5. #include <SDL2/SDL.h>
  6. #include <SDL2/SDL_image.h>
  7.  
  8. SDL_Texture* imageSlot1;
  9. SDL_Texture* imageSlot2;
  10. SDL_Texture* imageSlot3;
  11. SDL_Texture* imageSlot4;
  12. SDL_Texture* imageSlot5;
  13. SDL_Texture* imageSlot6;
  14. SDL_Texture* imageSlot7;
  15. SDL_Texture* imageSlot8;
  16. SDL_Texture* imageSlot9;
  17. SDL_Texture* imageSlot10;
  18.  
  19. SDL_Rect imageRect1;
  20. SDL_Rect imageRect2;
  21. SDL_Rect imageRect3;
  22. SDL_Rect imageRect4;
  23. SDL_Rect imageRect5;
  24. SDL_Rect imageRect6;
  25. SDL_Rect imageRect7;
  26. SDL_Rect imageRect8;
  27. SDL_Rect imageRect9;
  28. SDL_Rect imageRect10;
  29.  
  30. int imageIndex = 1;
  31.  
  32. extern SDL_Renderer* renderer;
  33.  
  34. void loadImage(const char* path, int posX, int posY, int sizeX, int sizeY)
  35. {
  36. switch(imageIndex)
  37. {
  38. case 1:
  39. imageRect1.x = posX;
  40. imageRect1.y = posY;
  41. imageRect1.w = sizeX;
  42. imageRect1.h = sizeY;
  43.  
  44. SDL_Surface* surface1;
  45.  
  46. surface1 = IMG_Load(path);
  47.  
  48. imageSlot1 = SDL_CreateTextureFromSurface(renderer, surface1);
  49.  
  50. SDL_FreeSurface(surface1);
  51.  
  52. imageIndex++;
  53. case 2:
  54. imageRect2.x = posX;
  55. imageRect2.y = posY;
  56. imageRect2.w = sizeX;
  57. imageRect2.h = sizeY;
  58.  
  59. SDL_Surface* surface2;
  60.  
  61. surface2 = IMG_Load(path);
  62.  
  63. imageSlot2 = SDL_CreateTextureFromSurface(renderer, surface2);
  64.  
  65. SDL_FreeSurface(surface2);
  66.  
  67. imageIndex++;
  68. case 3:
  69. imageRect3.x = posX;
  70. imageRect3.y = posY;
  71. imageRect3.w = sizeX;
  72. imageRect3.h = sizeY;
  73.  
  74. SDL_Surface* surface3;
  75.  
  76. surface3 = IMG_Load(path);
  77.  
  78. imageSlot3 = SDL_CreateTextureFromSurface(renderer, surface3);
  79.  
  80. SDL_FreeSurface(surface3);
  81.  
  82. imageIndex++;
  83. case 4:
  84. imageRect4.x = posX;
  85. imageRect4.y = posY;
  86. imageRect4.w = sizeX;
  87. imageRect4.h = sizeY;
  88.  
  89. SDL_Surface* surface4;
  90.  
  91. surface4 = IMG_Load(path);
  92.  
  93. imageSlot4 = SDL_CreateTextureFromSurface(renderer, surface4);
  94.  
  95. SDL_FreeSurface(surface4);
  96.  
  97. imageIndex++;
  98. case 5:
  99. imageRect5.x = posX;
  100. imageRect5.y = posY;
  101. imageRect5.w = sizeX;
  102. imageRect5.h = sizeY;
  103.  
  104. SDL_Surface* surface5;
  105.  
  106. surface5 = IMG_Load(path);
  107.  
  108. imageSlot5 = SDL_CreateTextureFromSurface(renderer, surface5);
  109.  
  110. SDL_FreeSurface(surface5);
  111.  
  112. imageIndex++;
  113. case 6:
  114. imageRect6.x = posX;
  115. imageRect6.y = posY;
  116. imageRect6.w = sizeX;
  117. imageRect6.h = sizeY;
  118.  
  119. SDL_Surface* surface6;
  120.  
  121. surface6 = IMG_Load(path);
  122.  
  123. imageSlot6 = SDL_CreateTextureFromSurface(renderer, surface6);
  124.  
  125. SDL_FreeSurface(surface6);
  126.  
  127. imageIndex++;
  128. case 7:
  129. imageRect7.x = posX;
  130. imageRect7.y = posY;
  131. imageRect7.w = sizeX;
  132. imageRect7.h = sizeY;
  133.  
  134. SDL_Surface* surface7;
  135.  
  136. surface7 = IMG_Load(path);
  137.  
  138. imageSlot7 = SDL_CreateTextureFromSurface(renderer, surface7);
  139.  
  140. SDL_FreeSurface(surface7);
  141.  
  142. imageIndex++;
  143. case 8:
  144. imageRect8.x = posX;
  145. imageRect8.y = posY;
  146. imageRect8.w = sizeX;
  147. imageRect8.h = sizeY;
  148.  
  149. SDL_Surface* surface8;
  150.  
  151. surface8 = IMG_Load(path);
  152.  
  153. imageSlot8 = SDL_CreateTextureFromSurface(renderer, surface8);
  154.  
  155. SDL_FreeSurface(surface8);
  156.  
  157. imageIndex++;
  158. case 9:
  159. imageRect9.x = posX;
  160. imageRect9.y = posY;
  161. imageRect9.w = sizeX;
  162. imageRect9.h = sizeY;
  163.  
  164. SDL_Surface* surface9;
  165.  
  166. surface9 = IMG_Load(path);
  167.  
  168. imageSlot9 = SDL_CreateTextureFromSurface(renderer, surface9);
  169.  
  170. SDL_FreeSurface(surface9);
  171.  
  172. imageIndex++;
  173. case 10:
  174. imageRect10.x = posX;
  175. imageRect10.y = posY;
  176. imageRect10.w = sizeX;
  177. imageRect10.h = sizeY;
  178.  
  179. SDL_Surface* surface10;
  180.  
  181. surface10 = IMG_Load(path);
  182.  
  183. imageSlot10 = SDL_CreateTextureFromSurface(renderer, surface10);
  184.  
  185. SDL_FreeSurface(surface10);
  186.  
  187. imageIndex++;
  188. }
  189. }
Add Comment
Please, Sign In to add comment