Add files via upload

This commit is contained in:
Андрей 2019-09-23 15:35:44 +03:00 committed by GitHub
parent bd6c0af022
commit 015cf96b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 10 deletions

View file

@ -9,8 +9,17 @@ int middleY;
int extentX; int extentX;
int extentY; int extentY;
struct Button {
RECT coords;
const char* text;
HDC picture;
};
void background(COLORREF color); void background(COLORREF color);
void drawMenu(); void drawMenu();
void drawButton(Button but);
void loadingAnimation(int delay);
void mainFunc();
int main() int main()
{ {
@ -25,6 +34,9 @@ int main()
txBegin(); txBegin();
txSleep(50);
loadingAnimation(10);
txSleep(1000);
drawMenu(); drawMenu();
txEnd(); txEnd();
@ -38,34 +50,60 @@ void background(COLORREF color)
txClear(); 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() void drawMenu()
{ {
RECT buttonPlay { //button "Play"
middleX - 100, extentY / 3 - 50, Button buttonPlay = {
middleX + 100, extentY / 3 + 50 {
middleX - 100, extentY / 3 - 50,
middleX + 100, extentY / 3 + 50
}, "Play"
}; };
RECT buttonExit { //button "Exit"
middleX - 100, extentY / 2 - 50, Button buttonExit = {
middleX + 100, extentY / 2 + 50 {
middleX - 100, extentY / 2 - 50,
middleX + 100, extentY / 2 + 50
}, "Exit"
}; };
txSetColor(TX_BLACK, 3); txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE); txSetFillColor(TX_WHITE);
txRectangle(buttonPlay.right, buttonPlay.top, buttonPlay.left, buttonPlay.bottom); drawButton(buttonPlay);
txRectangle(buttonExit.right, buttonExit.top, buttonExit.left, buttonExit.bottom); drawButton(buttonExit);
txSleep(50); txSleep(50);
while (!GetAsyncKeyState('Q')) { while (!GetAsyncKeyState('Q')) {
if (In(txMousePos(), buttonPlay) && txMouseButtons() & 1) { if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) { while (txMouseButtons() & 1) {
txSleep(10); txSleep(10);
} }
loadingAnimation(18);
txSleep(50);
mainFunc();
txMessageBox("Çàïóñê èãðû ïîêà ÷òî íå ðàáîòàåò!", "Îøèáêà"); txMessageBox("Çàïóñê èãðû ïîêà ÷òî íå ðàáîòàåò!", "Îøèáêà");
} }
if (In(txMousePos(), buttonExit) && txMouseButtons() & 1) { if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) { while (txMouseButtons() & 1) {
txSleep(10); 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);
}

BIN
pictures/block.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
pictures/question.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB