diff --git a/FallSimulation.cpp b/FallSimulation.cpp index e857987..78ebeac 100644 --- a/FallSimulation.cpp +++ b/FallSimulation.cpp @@ -9,8 +9,17 @@ int middleY; int extentX; int extentY; +struct Button { + RECT coords; + const char* text; + HDC picture; +}; + void background(COLORREF color); void drawMenu(); +void drawButton(Button but); +void loadingAnimation(int delay); +void mainFunc(); int main() { @@ -25,6 +34,9 @@ int main() txBegin(); + txSleep(50); + loadingAnimation(10); + txSleep(1000); drawMenu(); txEnd(); @@ -38,34 +50,60 @@ void background(COLORREF color) txClear(); } +void drawButton(Button but) +{ + //drawing button + txRectangle(but.coords.left, + but.coords.top, + but.coords.right, + but.coords.bottom); + + //drawing text + txDrawText (but.coords.left, + but.coords.top, + but.coords.right, + but.coords.bottom, + but.text); +} + void drawMenu() { - RECT buttonPlay { - middleX - 100, extentY / 3 - 50, - middleX + 100, extentY / 3 + 50 + //button "Play" + Button buttonPlay = { + { + middleX - 100, extentY / 3 - 50, + middleX + 100, extentY / 3 + 50 + }, "Play" }; - RECT buttonExit { - middleX - 100, extentY / 2 - 50, - middleX + 100, extentY / 2 + 50 + //button "Exit" + Button buttonExit = { + { + middleX - 100, extentY / 2 - 50, + middleX + 100, extentY / 2 + 50 + }, "Exit" }; txSetColor(TX_BLACK, 3); txSetFillColor(TX_WHITE); - txRectangle(buttonPlay.right, buttonPlay.top, buttonPlay.left, buttonPlay.bottom); - txRectangle(buttonExit.right, buttonExit.top, buttonExit.left, buttonExit.bottom); + drawButton(buttonPlay); + drawButton(buttonExit); + txSleep(50); while (!GetAsyncKeyState('Q')) { - if (In(txMousePos(), buttonPlay) && txMouseButtons() & 1) { + if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) { while (txMouseButtons() & 1) { txSleep(10); } + loadingAnimation(18); + txSleep(50); + mainFunc(); txMessageBox("Запуск игры пока что не работает!", "Ошибка"); } - if (In(txMousePos(), buttonExit) && txMouseButtons() & 1) { + if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) { while (txMouseButtons() & 1) { txSleep(10); } @@ -75,3 +113,31 @@ void drawMenu() } } +void loadingAnimation(int delay) +{ + background(TX_WHITE); + + for (int circle_radius = 0; + circle_radius * circle_radius < extentX * extentX + extentY * extentY; + circle_radius += 3) { + + txSetColor(TX_BLACK, 2); + txSetFillColor(TX_BLACK); + + txCircle(0, 0, circle_radius); + + txSleep(delay); + } + + background(TX_WHITE); +} + +void mainFunc() +{ + HDC block = txLoadImage("pictures\\block.bmp"); + HDC quest = txLoadImage("pictures\\question.bmp"); + + txBitBlt(txDC(), extentX - 60, 0, 60, 60, block); + txBitBlt(txDC(), extentX - 60, 60, 60, 60, quest); +} + diff --git a/pictures/block.bmp b/pictures/block.bmp new file mode 100644 index 0000000..288ab1c Binary files /dev/null and b/pictures/block.bmp differ diff --git a/pictures/question.bmp b/pictures/question.bmp new file mode 100644 index 0000000..0a816bb Binary files /dev/null and b/pictures/question.bmp differ