Advertisement
Guest User

Proiectul vechi

a guest
Dec 13th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <graphics.h>
  3. #include <winbgim.h>
  4.  
  5. using namespace std;
  6.  
  7. int midx = 640;
  8. int midy = 360;
  9.  
  10. void openGame();
  11. void afiseazaMeniu();
  12. void alegeOptiune();
  13. void alegeNivel();
  14. void joaca();
  15. void afiseazaNivele();
  16. void closeGame();
  17.  
  18. int main()
  19. {
  20.     openGame();
  21.     closeGame();
  22.     return 0;
  23. }
  24.  
  25. void openGame()
  26. {
  27.     initwindow(1280, 720,"Pirates Hide & Seek");
  28.     readimagefile("background_16x9_pixel.jpg", 0, 0, 1270, 710);
  29.     afiseazaMeniu();
  30.     alegeOptiune();
  31. }
  32. void afiseazaMeniu()
  33. {
  34.     settextstyle(3, HORIZ_DIR, 9);
  35.     setcolor(15);
  36.     setbkcolor(0);
  37.     //Titlu
  38.     int width = textwidth("Pirates Hide & Seek");
  39.     int height = textheight("Pirates Hide & Seek");
  40.     outtextxy(midx - width / 2, (midy - height / 2) / 4, "Pirates Hide & Seek");
  41.     ///Play
  42.     settextstyle(3, HORIZ_DIR, 8);
  43.     width = textwidth("Play");
  44.     height = textheight("Play");
  45.     outtextxy(midx - width / 2, (midy - height / 2)-50, "Play");
  46.     //ellipse(midx, midy-50, 0, 360, width/2, height/2);
  47.     ///Instructiuni
  48.     width = textwidth("Instructiuni");
  49.     height = textheight("Instructiuni");
  50.     outtextxy(midx - width / 2, (midy - height / 2)+75, "Instructiuni");
  51.     //ellipse(midx, midy+75, 0, 360, width / 2, height / 2);
  52.     ///Exit
  53.     settextstyle(3, HORIZ_DIR, 8);
  54.     width = textwidth("Exit");
  55.     height = textheight("Exit");
  56.     outtextxy(midx - width / 2, (midy - height / 2)+200, "Exit");
  57. }
  58. void alegeOptiune()
  59. {
  60.     int x, y,width,height;
  61.     while (!ismouseclick(WM_LBUTTONDOWN));
  62.     getmouseclick(WM_LBUTTONDOWN, x, y);
  63.     width = textwidth("Play");
  64.     height = textheight("Play");
  65.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - 50 - height / 2 && y <= midy -50 + height / 2)
  66.     {
  67.         clearmouseclick(WM_LBUTTONDOWN);
  68.         alegeNivel();
  69.     }
  70.     width = textwidth("Instructiuni");
  71.     height = textheight("Instructiuni");
  72.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 75 - height / 2 && y <= midy + 75 + height / 2)
  73.     {
  74.         clearmouseclick(WM_LBUTTONDOWN);
  75.         cleardevice();
  76.         width = textwidth("Morena");
  77.         height = textheight("Morena");
  78.         outtextxy(midx - width / 2, midy - height / 2, "Morena");
  79.         getch();
  80.     }
  81.     width = textwidth("Exit");
  82.     height = textheight("Exit");
  83.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 200 - height / 2 && y <= midy + 200 + height / 2)
  84.     {
  85.         clearmouseclick(WM_LBUTTONDOWN);
  86.         exit;
  87.     }
  88. }
  89. void alegeNivel()
  90. {
  91.     afiseazaNivele();
  92.     int x, y, width, height;
  93.     while (!ismouseclick(WM_LBUTTONDOWN));
  94.     getmouseclick(WM_LBUTTONDOWN, x, y);
  95.     width = textwidth("Nivel 1");
  96.     height = textheight("Nivel 1");
  97.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - 200 - height / 2 && y <= midy - 200 + height / 2)
  98.     {
  99.         cleardevice();
  100.         readimagefile("BOARD1.jpg", 400, 100, 880, 620);
  101.         joaca();
  102.         getch();
  103.     }
  104.     width = textwidth("Nivel 2");
  105.     height = textheight("Nivel 2");
  106.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - height / 2 && y <= midy + height / 2)
  107.     {
  108.         cleardevice();
  109.         readimagefile("BOARD1.jpg", 400, 100, 880, 620);
  110.         getch();
  111.     }
  112.     width = textwidth("Nivel 3");
  113.     height = textheight("Nivel 3");
  114.     if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 200 - height / 2 && y <= midy + 200 + height / 2)
  115.     {
  116.         cleardevice();
  117.         readimagefile("BOARD1.jpg", 400, 100, 880, 620);
  118.         getch();
  119.     }
  120. }
  121. void joaca()
  122. {
  123.  
  124. }
  125. void afiseazaNivele()
  126. {
  127.     int width, height;
  128.     cleardevice();
  129.     readimagefile("sky.jpg", 0, 0, 1270, 710);
  130.     settextstyle(3, HORIZ_DIR, 9);
  131.     setcolor(15);
  132.     setbkcolor(0);
  133.     width = textwidth("Nivel 1");
  134.     height = textheight("Nivel 1");
  135.     outtextxy(midx - width / 2, midy - height / 2 - 200, "Nivel 1");
  136.     width = textwidth("Nivel 2");
  137.     height = textheight("Nivel 2");
  138.     outtextxy(midx - width / 2, midy - height / 2, "Nivel 2");
  139.     width = textwidth("Nivel 3");
  140.     height = textheight("Nivel 3");
  141.     outtextxy(midx - width / 2, midy - height / 2 + 200, "Nivel 3");
  142. }
  143. void closeGame()
  144. {
  145.     closegraph();
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement