Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <graphics.h>
- #include <winbgim.h>
- using namespace std;
- int midx = 640;
- int midy = 360;
- void openGame();
- void afiseazaMeniu();
- void alegeOptiune();
- void alegeNivel();
- void joaca();
- void afiseazaNivele();
- void closeGame();
- int main()
- {
- openGame();
- closeGame();
- return 0;
- }
- void openGame()
- {
- initwindow(1280, 720,"Pirates Hide & Seek");
- readimagefile("background_16x9_pixel.jpg", 0, 0, 1270, 710);
- afiseazaMeniu();
- alegeOptiune();
- }
- void afiseazaMeniu()
- {
- settextstyle(3, HORIZ_DIR, 9);
- setcolor(15);
- setbkcolor(0);
- //Titlu
- int width = textwidth("Pirates Hide & Seek");
- int height = textheight("Pirates Hide & Seek");
- outtextxy(midx - width / 2, (midy - height / 2) / 4, "Pirates Hide & Seek");
- ///Play
- settextstyle(3, HORIZ_DIR, 8);
- width = textwidth("Play");
- height = textheight("Play");
- outtextxy(midx - width / 2, (midy - height / 2)-50, "Play");
- //ellipse(midx, midy-50, 0, 360, width/2, height/2);
- ///Instructiuni
- width = textwidth("Instructiuni");
- height = textheight("Instructiuni");
- outtextxy(midx - width / 2, (midy - height / 2)+75, "Instructiuni");
- //ellipse(midx, midy+75, 0, 360, width / 2, height / 2);
- ///Exit
- settextstyle(3, HORIZ_DIR, 8);
- width = textwidth("Exit");
- height = textheight("Exit");
- outtextxy(midx - width / 2, (midy - height / 2)+200, "Exit");
- }
- void alegeOptiune()
- {
- int x, y,width,height;
- while (!ismouseclick(WM_LBUTTONDOWN));
- getmouseclick(WM_LBUTTONDOWN, x, y);
- width = textwidth("Play");
- height = textheight("Play");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - 50 - height / 2 && y <= midy -50 + height / 2)
- {
- clearmouseclick(WM_LBUTTONDOWN);
- alegeNivel();
- }
- width = textwidth("Instructiuni");
- height = textheight("Instructiuni");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 75 - height / 2 && y <= midy + 75 + height / 2)
- {
- clearmouseclick(WM_LBUTTONDOWN);
- cleardevice();
- width = textwidth("Morena");
- height = textheight("Morena");
- outtextxy(midx - width / 2, midy - height / 2, "Morena");
- getch();
- }
- width = textwidth("Exit");
- height = textheight("Exit");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 200 - height / 2 && y <= midy + 200 + height / 2)
- {
- clearmouseclick(WM_LBUTTONDOWN);
- exit;
- }
- }
- void alegeNivel()
- {
- afiseazaNivele();
- int x, y, width, height;
- while (!ismouseclick(WM_LBUTTONDOWN));
- getmouseclick(WM_LBUTTONDOWN, x, y);
- width = textwidth("Nivel 1");
- height = textheight("Nivel 1");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - 200 - height / 2 && y <= midy - 200 + height / 2)
- {
- cleardevice();
- readimagefile("BOARD1.jpg", 400, 100, 880, 620);
- joaca();
- getch();
- }
- width = textwidth("Nivel 2");
- height = textheight("Nivel 2");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy - height / 2 && y <= midy + height / 2)
- {
- cleardevice();
- readimagefile("BOARD1.jpg", 400, 100, 880, 620);
- getch();
- }
- width = textwidth("Nivel 3");
- height = textheight("Nivel 3");
- if (x >= midx - width / 2 && x <= midx + width / 2 && y >= midy + 200 - height / 2 && y <= midy + 200 + height / 2)
- {
- cleardevice();
- readimagefile("BOARD1.jpg", 400, 100, 880, 620);
- getch();
- }
- }
- void joaca()
- {
- }
- void afiseazaNivele()
- {
- int width, height;
- cleardevice();
- readimagefile("sky.jpg", 0, 0, 1270, 710);
- settextstyle(3, HORIZ_DIR, 9);
- setcolor(15);
- setbkcolor(0);
- width = textwidth("Nivel 1");
- height = textheight("Nivel 1");
- outtextxy(midx - width / 2, midy - height / 2 - 200, "Nivel 1");
- width = textwidth("Nivel 2");
- height = textheight("Nivel 2");
- outtextxy(midx - width / 2, midy - height / 2, "Nivel 2");
- width = textwidth("Nivel 3");
- height = textheight("Nivel 3");
- outtextxy(midx - width / 2, midy - height / 2 + 200, "Nivel 3");
- }
- void closeGame()
- {
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement