diff --git a/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj b/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj index bb0b9ef..48b58f6 100644 --- a/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj +++ b/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj @@ -139,7 +139,6 @@ - diff --git a/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj.filters b/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj.filters index 85db392..02556c9 100644 --- a/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj.filters +++ b/lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj.filters @@ -30,9 +30,6 @@ Файлы заголовков - - Файлы заголовков - diff --git a/lab16 with raylib/resources/Inconsolata-LGC-Bold.ttf b/lab16 with raylib/resources/Inconsolata-LGC-Bold.ttf new file mode 100644 index 0000000..1c00e7f Binary files /dev/null and b/lab16 with raylib/resources/Inconsolata-LGC-Bold.ttf differ diff --git a/lab16 with raylib/resources/Inconsolata-LGC.ttf b/lab16 with raylib/resources/Inconsolata-LGC.ttf new file mode 100644 index 0000000..09f1738 Binary files /dev/null and b/lab16 with raylib/resources/Inconsolata-LGC.ttf differ diff --git a/lab16 with raylib/resources/savefile.txt b/lab16 with raylib/resources/savefile.txt index a596a4f..b3b05d2 100644 --- a/lab16 with raylib/resources/savefile.txt +++ b/lab16 with raylib/resources/savefile.txt @@ -1,13 +1,13 @@ -10 55 +10 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 3 0 0 3 0 0 0 0 0 -0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 -0 0 0 3 0 3 3 3 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 -0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 3 0 0 0 0 2 0 -0 0 0 0 0 0 0 2 0 0 0 0 0 2 0 -0 0 0 0 0 0 2 2 2 2 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 20 5 -11 6 3 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 9 34 +3 4 2 diff --git a/lab16 with raylib/src/fonts.py b/lab16 with raylib/src/fonts.py new file mode 100644 index 0000000..9d91db8 --- /dev/null +++ b/lab16 with raylib/src/fonts.py @@ -0,0 +1,22 @@ +from itertools import chain +import sys + +from fontTools.ttLib import TTFont +from fontTools.unicode import Unicode + +with TTFont( + sys.argv[1], 0, allowVID=0, ignoreDecompileErrors=True, fontNumber=-1 +) as ttf: + chars = chain.from_iterable( + [y + (Unicode[y[0]],) for y in x.cmap.items()] for x in ttf["cmap"].tables + ) + if len(sys.argv) == 2: # print all code points + for c in chars: + print(c) + elif len(sys.argv) >= 3: # search code points / characters + code_points = {c[0] for c in chars} + for i in sys.argv[2:]: + code_point = int(i) # search code point + #code_point = ord(i) # search character + print(Unicode[code_point]) + print(code_point in code_points) \ No newline at end of file diff --git a/lab16 with raylib/src/main.c b/lab16 with raylib/src/main.c index d44989a..571566c 100644 --- a/lab16 with raylib/src/main.c +++ b/lab16 with raylib/src/main.c @@ -1,4 +1,4 @@ -#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #include #include #include "raylib.h" @@ -14,15 +14,16 @@ #define HEIGHT 50 #define WIDTH 50 #define VOFFSET 50 + #define PUREBLUE (Color) { 0, 0, 255, 255 } #define BLACKGRAY (Color) {30, 30, 30, 255} #define VSGRAY (Color) {78, 201, 176, 255} -// : -// 0 - +// Коды ячеек: +// 0 - свободна // 1 - -// 2 - -// 3 - +// 2 - препятствие +// 3 - золото int map[M][N] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0}, @@ -146,11 +147,11 @@ void drawNet() { } void drawMap() { - // : - // 0 - + // Коды ячеек: + // 0 - свободна // 1 - - // 2 - - // 3 - + // 2 - препятствие + // 3 - золото Color colors[4] = { LIGHTGRAY, PUREBLUE, BLACK, YELLOW }; for (int i = 0; i < M; i++) { @@ -194,10 +195,11 @@ void drawBottomBar(Font font, float fontSize) { void save() { FILE* fout = fopen("savefile.txt", "w"); if (fout == NULL) { - GuiMessageBox((Rectangle) { N * WIDTH / 2 - 50 , M*HEIGHT - 50, N * WIDTH / 2 + 50 , M*HEIGHT + 50,}, - " ", - " ", - ";"); + /*GuiMessageBox((Rectangle) { N * WIDTH / 2 - 50 , M*HEIGHT - 50, N * WIDTH / 2 + 50 , M*HEIGHT + 50,}, + "Ошибка сохранения", + "Невозможно создать файл", + "Ок;Выйти");*/ + printf("save error"); return; } @@ -222,21 +224,21 @@ void save() { void load() { FILE* fin = fopen("savefile.txt", "r"); if (fin == NULL) { - printf("error"); - GuiMessageBox((Rectangle) { N* WIDTH / 2 - 50, M* HEIGHT - 50, N* WIDTH / 2 + 50, M* HEIGHT + 50, }, - " ", - " \n ", - ";"); + printf("1) load error\n"); + /*GuiMessageBox((Rectangle) { N* WIDTH / 2 - 50, M* HEIGHT - 50, N* WIDTH / 2 + 50, M* HEIGHT + 50, }, + "Ошибка загрузки", + "Файл не найден\nПопробуйте сначала сохранить игру", + "Ок;Выйти");*/ return; } int m, n; fscanf_s(fin, "%d%d", &m, &n); if (m != M || n != N) { - printf("error"); - GuiMessageBox((Rectangle) { N* WIDTH / 2 - 50, M* HEIGHT - 50, N* WIDTH / 2 + 50, M* HEIGHT + 50, }, - " ", - " !\n ", - ";"); + printf("2) load error\n"); + /*GuiMessageBox((Rectangle) { N* WIDTH / 2 - 50, M* HEIGHT - 50, N* WIDTH / 2 + 50, M* HEIGHT + 50, }, + "Ошибка загрузки", + "Неправильный размер карты!\nПроверьте целостность сохранения", + "Ок;Выйти");*/ return; } for (int i = 0; i < m; i++) { @@ -255,60 +257,65 @@ void load() { } void handleKeys() { - switch (GetKeyPressed()) - { - case KEY_F5: - save(); - break; - case KEY_F9: - load(); - break; - case KEY_SPACE: - netToggle = !netToggle; - break; - case KEY_W: - movePlayer(up); - break; - case KEY_S: - movePlayer(down); - break; - case KEY_D: - movePlayer(right); - break; - case KEY_A: - movePlayer(left); - break; - case KEY_ONE: - stomp(1); - break; - case KEY_TWO: - stomp(2); - break; - case KEY_Z: - deathbeam(right); - break; - case KEY_M: - doMidashand(); - break; - case KEY_G: - if (selected_element == gold) selected_element = wall; - else selected_element = gold; - break; - case KEY_LEFT: - putElement(left, selected_element); - break; - case KEY_RIGHT: - putElement(right, selected_element); - break; - case KEY_UP: - putElement(up, selected_element); - break; - case KEY_DOWN: - putElement(down, selected_element); - break; + int key; + while (key = GetKeyPressed()) { + switch (key) + { + case KEY_F5: + save(); + break; + case KEY_F9: + load(); + break; + case KEY_SPACE: + netToggle = !netToggle; + break; + case KEY_W: + movePlayer(up); + break; + case KEY_S: + movePlayer(down); + break; + case KEY_D: + movePlayer(right); + break; + case KEY_A: + movePlayer(left); + break; + case KEY_ONE: + stomp(1); + break; + case KEY_TWO: + stomp(2); + break; + case KEY_Z: + deathbeam(right); + break; + case KEY_M: + doMidashand(); + break; + case KEY_G: + if (selected_element == gold) selected_element = wall; + else selected_element = gold; + break; + case KEY_LEFT: + putElement(left, selected_element); + break; + case KEY_RIGHT: + putElement(right, selected_element); + break; + case KEY_UP: + putElement(up, selected_element); + break; + case KEY_DOWN: + putElement(down, selected_element); + break; + } } } + +#define CDPSIZE 213 int main() { //SetConfigFlags(FLAG_WINDOW_HIGHDPI); @@ -318,10 +325,16 @@ int main() { SearchAndSetResourceDir("resources"); + int codepoints[CDPSIZE] = { 0 }; + for (int i = 0; i < 127 - 32; i++) codepoints[i] = 32 + i; // Basic ASCII characters + for (int i = 0; i < 118; i++) codepoints[95 + i] = 1024 + i; // Cyrillic characters + //Font InconsolataRegular = LoadFontEx("Inconsolata-Regular.ttf", 24, NULL, 0); - Font InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, NULL, 0); - SetTextureFilter(InconsolataSemiBold.texture, TEXTURE_FILTER_BILINEAR); - //Font InconsolataBold = LoadFontEx("Inconsolata-Bold.ttf", 24, NULL, 0); + //Font InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, codepoints, 512); + Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 48, codepoints, CDPSIZE); + SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR); + + //GuiSetFont(InconsolataBold); // game loop while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window @@ -336,18 +349,22 @@ int main() { drawMap(); drawPlayer(); - drawBottomBar(InconsolataSemiBold, 24); + drawBottomBar(InconsolataBold, 24); if (netToggle) { drawNet(); } + + // show FPS and frametime + //DrawText(TextFormat("%2d FPS", GetFPS()), 0, 0, 34, ORANGE); + //DrawText(TextFormat("%4f ms", GetFrameTime()), 0, 34, 34, BEIGE); // end the frame and get ready for the next one (display frame, poll input, etc...) EndDrawing(); } //UnloadFont(InconsolataRegular); - UnloadFont(InconsolataSemiBold); + UnloadFont(InconsolataBold); //UnloadFont(InconsolataBold); // destroy the window and cleanup the OpenGL context diff --git a/lab16 with raylib/src/Вывод-Сборка.txt b/lab16 with raylib/src/Вывод-Сборка.txt new file mode 100644 index 0000000..e69de29 diff --git a/raylib files/InconsolataLGC-1.9.0.tar.xz b/raylib files/InconsolataLGC-1.9.0.tar.xz new file mode 100644 index 0000000..e5b16fa Binary files /dev/null and b/raylib files/InconsolataLGC-1.9.0.tar.xz differ