From 2bcc4b083ea80e2350bc7451cdb92f47b74a1e8a Mon Sep 17 00:00:00 2001 From: Kaehvaman Date: Fri, 1 Nov 2024 20:04:42 +0400 Subject: [PATCH] finished lab18 --- lab16/lab16/lab16.cpp | 4 +-- lab16/lab16/savefile.txt | 13 -------- lab18/lab18/lab18.cpp | 52 +++++++++++++++++++++++++---- lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp | 2 +- 4 files changed, 49 insertions(+), 22 deletions(-) delete mode 100644 lab16/lab16/savefile.txt diff --git a/lab16/lab16/lab16.cpp b/lab16/lab16/lab16.cpp index d1fcab4..50f9aef 100644 --- a/lab16/lab16/lab16.cpp +++ b/lab16/lab16/lab16.cpp @@ -178,7 +178,7 @@ void movePlayer(enum_ways move) { break; } if (map[player_y][player_x] == gold) { - map[player_y][player_x] = 0; + map[player_y][player_x] = empty; inventory[gold]++; } } @@ -325,7 +325,7 @@ void drawBottomBar(HDC hdc) { CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH, TEXT("Consolas")); SelectObject(hdc, hFont); - SetTextColor(hdc, RGB(78, 201, 176)); + SetTextColor(hdc, RGB(0, 0, 0)); //SetBkColor(hdc, RGB(255, 0, 0)); SetBkMode(hdc, TRANSPARENT); DrawTextA(hdc, gold_string, -1, &itemrect, (DT_SINGLELINE | DT_TOP | DT_LEFT)); diff --git a/lab16/lab16/savefile.txt b/lab16/lab16/savefile.txt deleted file mode 100644 index e62c7fd..0000000 --- a/lab16/lab16/savefile.txt +++ /dev/null @@ -1,13 +0,0 @@ -10 15 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 2 2 0 0 0 0 2 0 3 0 0 0 0 0 -0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 -0 0 0 3 3 3 3 0 0 0 3 3 0 0 0 -0 0 0 0 0 0 3 0 0 0 3 3 0 0 0 -0 0 0 0 0 0 3 3 3 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 3 0 2 0 0 2 0 -0 0 2 0 0 0 0 2 0 0 2 0 0 2 0 -0 0 0 0 0 0 2 2 2 2 2 2 2 2 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 15 0 -1 1 3 diff --git a/lab18/lab18/lab18.cpp b/lab18/lab18/lab18.cpp index d04acf7..0e7a3d2 100644 --- a/lab18/lab18/lab18.cpp +++ b/lab18/lab18/lab18.cpp @@ -3,6 +3,7 @@ #include "framework.h" #include "lab18.h" +#include "stdio.h" #define MAX_LOADSTRING 100 @@ -173,7 +174,7 @@ void drawRomb(HDC hdc, int cx, int cy, int size) { } void drawStar(HDC hdc, int cx, int cy, int size) { - HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 180, 200)); + HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 180, 255)); SelectObject(hdc, hPen); POINT p[9] = { @@ -192,6 +193,15 @@ void drawStar(HDC hdc, int cx, int cy, int size) { DeleteObject(hPen); } +void drawCirle(HDC hdc, int cx, int cy, int size) { + HPEN hPen = CreatePen(PS_SOLID, 3, RGB(255, 0, 255)); + SelectObject(hdc, hPen); + + Ellipse(hdc, cx - size, cy - size, cx + size, cy + size); + + DeleteObject(hPen); +} + void drawRecursiveTriangle(HDC hdc, int cx, int cy, int size, int mode) { drawTriangle(hdc, cx, cy, size); @@ -237,10 +247,37 @@ void drawRecursiveStar(HDC hdc, int cx, int cy, int size, int mode) { if (size < 20) { return; } - if (mode == drawRecursiveStar(hdc, cx - size, cy, size / 2, mode); - drawRecursiveStar(hdc, cx + size, cy, size / 2, mode); - if (mode == 1 || mode == 3) drawRecursiveStar(hdc, cx, cy + size, size / 2, mode); - if (mode == 2 || mode == 3) drawRecursiveStar(hdc, cx, cy - size, size / 2, mode); + if (mode == 0 || mode == 2) drawRecursiveStar(hdc, cx - size, cy, size / 2, mode); + if (mode == 0) drawRecursiveStar(hdc, cx + size, cy, size / 2, mode); + if (mode == 1 || mode == 2) drawRecursiveStar(hdc, cx, cy + size, size / 2, mode); + if (mode == 1 || mode == 2) drawRecursiveStar(hdc, cx, cy - size, size / 2, mode); +} + +int circlecount = 0; +void drawRecursiveCircle(HDC hdc, int cx, int cy, int size, int i) { + drawCirle(hdc, cx, cy, size); + i--; + circlecount++; + + static HFONT hFont = CreateFontW(18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, + CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH, TEXT("Consolas")); + + SelectObject(hdc, hFont); + SetTextColor(hdc, RGB(0, 0, 0)); + SetBkMode(hdc, TRANSPARENT); + + static char circle_string[10]; + sprintf_s(circle_string, "%d", circlecount); + RECT circlerect = { cx - size, cy - size, cx + size, cy + size }; + + DrawTextA(hdc, circle_string, -1, &circlerect, (DT_SINGLELINE | DT_VCENTER | DT_CENTER)); + + if (i == 0) { + return; + } + + drawRecursiveCircle(hdc, cx, cy - size, size / 2, i); + drawRecursiveCircle(hdc, cx + size, cy, size / 2, i); } int trmode = 0; @@ -291,11 +328,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (netToggle) drawNet(hdc, rect.right, rect.bottom, 50, 50); drawRecursiveTriangle(hdc, 300, 300, 100, trmode); - drawRecursiveHourglass(hdc, 600, 300, 100, hgmode); + drawRecursiveHourglass(hdc, 700, 300, 100, hgmode); //drawRecursiveRomb(hdc, 1100, 300, 100, rbmode); drawRecursiveStar(hdc, 1100, 300, 100, rbmode); + drawRecursiveCircle(hdc, 500, 500, 200, 5); + circlecount = 0; + EndPaint(hWnd, &ps); } break; diff --git a/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp b/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp index 6a13a0d..5acfac0 100644 --- a/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp +++ b/lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp @@ -558,7 +558,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (netToggle) drawNet(hdc, rect.right, rect.bottom); //drawNet(hdc, 1400, 650); - //drawImageSequence1(hdc); + drawImageSequence1(hdc); //lab5(hdc);