mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-30 08:48:25 +04:00
add logo.ico
This commit is contained in:
parent
b7ccb8ad21
commit
f193f212a5
BIN
lab16 with raylib/lab16 with raylib/lab16 with raylib.rc
Normal file
BIN
lab16 with raylib/lab16 with raylib/lab16 with raylib.rc
Normal file
Binary file not shown.
@ -124,12 +124,13 @@
|
|||||||
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>raylib.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>raylib.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -137,10 +138,18 @@
|
|||||||
<ClInclude Include="..\include\raylib.h" />
|
<ClInclude Include="..\include\raylib.h" />
|
||||||
<ClInclude Include="..\include\raymath.h" />
|
<ClInclude Include="..\include\raymath.h" />
|
||||||
<ClInclude Include="..\include\resource_dir.h" />
|
<ClInclude Include="..\include\resource_dir.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="resource1.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\src\main.c" />
|
<ClCompile Include="..\src\main.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="lab16 with raylib.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="..\resources\logo.ico" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
@ -27,10 +27,26 @@
|
|||||||
<ClInclude Include="..\include\resource_dir.h">
|
<ClInclude Include="..\include\resource_dir.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource1.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\src\main.c">
|
<ClCompile Include="..\src\main.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="lab16 with raylib.rc">
|
||||||
|
<Filter>Файлы ресурсов</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="..\resources\logo.ico">
|
||||||
|
<Filter>Файлы ресурсов</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
16
lab16 with raylib/lab16 with raylib/resource.h
Normal file
16
lab16 with raylib/lab16 with raylib/resource.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Âêëþ÷àåìûé ôàéë, ñîçäàííûé â Microsoft Visual C++.
|
||||||
|
// Èñïîëüçóåòñÿ lab16 with raylib.rc
|
||||||
|
//
|
||||||
|
#define IDI_ICON1 101
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
BIN
lab16 with raylib/resources/logo.ico
Normal file
BIN
lab16 with raylib/resources/logo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@ -1,356 +1,356 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iso646.h>
|
#include <iso646.h>
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#include "raygui.h"
|
#include "raygui.h"
|
||||||
|
|
||||||
#include "resource_dir.h"
|
#include "resource_dir.h"
|
||||||
|
|
||||||
#define M 10
|
#define M 10
|
||||||
#define N 15
|
#define N 15
|
||||||
#define HEIGHT 50
|
#define HEIGHT 50
|
||||||
#define WIDTH 50
|
#define WIDTH 50
|
||||||
#define VOFFSET 50
|
#define VOFFSET 50
|
||||||
#define PUREBLUE (Color) { 0, 0, 255, 255 }
|
#define PUREBLUE (Color) { 0, 0, 255, 255 }
|
||||||
#define BLACKGRAY (Color) {30, 30, 30, 255}
|
#define BLACKGRAY (Color) {30, 30, 30, 255}
|
||||||
#define VSGRAY (Color) {78, 201, 176, 255}
|
#define VSGRAY (Color) {78, 201, 176, 255}
|
||||||
|
|
||||||
// Êîäû ÿ÷ååê:
|
// Êîäû ÿ÷ååê:
|
||||||
// 0 - ñâîáîäíà
|
// 0 - ñâîáîäíà
|
||||||
// 1 -
|
// 1 -
|
||||||
// 2 - ïðåïÿòñòâèå
|
// 2 - ïðåïÿòñòâèå
|
||||||
// 3 - çîëîòî
|
// 3 - çîëîòî
|
||||||
int map[M][N] = {
|
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, 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, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 0, 2, 0},
|
||||||
{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0},
|
{0, 0, 0, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
int player_x = 1;
|
int player_x = 1;
|
||||||
int player_y = 1;
|
int player_y = 1;
|
||||||
|
|
||||||
typedef enum obj_enum { empty = 0, wall = 2, gold = 3 } obj_enum;
|
typedef enum obj_enum { empty = 0, wall = 2, gold = 3 } obj_enum;
|
||||||
// TODO: do something with "empty" object
|
// TODO: do something with "empty" object
|
||||||
#define INVENTORY_SIZE 4
|
#define INVENTORY_SIZE 4
|
||||||
int inventory[INVENTORY_SIZE] = { 0, 0, 15, 0 };
|
int inventory[INVENTORY_SIZE] = { 0, 0, 15, 0 };
|
||||||
obj_enum selected_element = gold;
|
obj_enum selected_element = gold;
|
||||||
|
|
||||||
typedef enum enum_ways { left, right, up, down } enum_ways;
|
typedef enum enum_ways { left, right, up, down } enum_ways;
|
||||||
void movePlayer(enum_ways move) {
|
void movePlayer(enum_ways move) {
|
||||||
switch (move) {
|
switch (move) {
|
||||||
case left:
|
case left:
|
||||||
if ((player_x > 0) and map[player_y][player_x - 1] != wall) player_x -= 1;
|
if ((player_x > 0) and map[player_y][player_x - 1] != wall) player_x -= 1;
|
||||||
break;
|
break;
|
||||||
case right:
|
case right:
|
||||||
if ((player_x < N - 1) and map[player_y][player_x + 1] != wall) player_x += 1;
|
if ((player_x < N - 1) and map[player_y][player_x + 1] != wall) player_x += 1;
|
||||||
break;
|
break;
|
||||||
case up:
|
case up:
|
||||||
if ((player_y > 0) and map[player_y - 1][player_x] != wall) player_y -= 1;
|
if ((player_y > 0) and map[player_y - 1][player_x] != wall) player_y -= 1;
|
||||||
break;
|
break;
|
||||||
case down:
|
case down:
|
||||||
if ((player_y < M - 1) and map[player_y + 1][player_x] != wall) player_y += 1;
|
if ((player_y < M - 1) and map[player_y + 1][player_x] != wall) player_y += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (map[player_y][player_x] == gold) {
|
if (map[player_y][player_x] == gold) {
|
||||||
map[player_y][player_x] = empty;
|
map[player_y][player_x] = empty;
|
||||||
inventory[gold]++;
|
inventory[gold]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void putElement(enum_ways way, obj_enum element) {
|
void putElement(enum_ways way, obj_enum element) {
|
||||||
if (element != empty && inventory[element] == 0) return;
|
if (element != empty && inventory[element] == 0) return;
|
||||||
|
|
||||||
switch (way) {
|
switch (way) {
|
||||||
case left:
|
case left:
|
||||||
if ((player_x > 0) and map[player_y][player_x - 1] == 0) {
|
if ((player_x > 0) and map[player_y][player_x - 1] == 0) {
|
||||||
map[player_y][player_x - 1] = element;
|
map[player_y][player_x - 1] = element;
|
||||||
inventory[element]--;
|
inventory[element]--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case right:
|
case right:
|
||||||
if ((player_x < N - 1) and map[player_y][player_x + 1] == 0) {
|
if ((player_x < N - 1) and map[player_y][player_x + 1] == 0) {
|
||||||
map[player_y][player_x + 1] = element;
|
map[player_y][player_x + 1] = element;
|
||||||
inventory[element]--;
|
inventory[element]--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case up:
|
case up:
|
||||||
if ((player_y > 0) and map[player_y - 1][player_x] == 0) {
|
if ((player_y > 0) and map[player_y - 1][player_x] == 0) {
|
||||||
map[player_y - 1][player_x] = element;
|
map[player_y - 1][player_x] = element;
|
||||||
inventory[element]--;
|
inventory[element]--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case down:
|
case down:
|
||||||
if ((player_y < M - 1) and map[player_y + 1][player_x] == 0) {
|
if ((player_y < M - 1) and map[player_y + 1][player_x] == 0) {
|
||||||
map[player_y + 1][player_x] = element;
|
map[player_y + 1][player_x] = element;
|
||||||
inventory[element]--;
|
inventory[element]--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deathbeam(enum_ways way) {
|
void deathbeam(enum_ways way) {
|
||||||
for (int i = player_x + 1; i < N; i++) {
|
for (int i = player_x + 1; i < N; i++) {
|
||||||
if (map[player_y][i] != empty) inventory[map[player_y][i]] += 1;
|
if (map[player_y][i] != empty) inventory[map[player_y][i]] += 1;
|
||||||
map[player_y][i] = 0;
|
map[player_y][i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stomp(int r) {
|
void stomp(int r) {
|
||||||
for (int i = 0; i < M; i++) {
|
for (int i = 0; i < M; i++) {
|
||||||
for (int j = 0; j < N; j++) {
|
for (int j = 0; j < N; j++) {
|
||||||
if ((player_y - r <= i) && (i <= player_y + r) && (player_x - r <= j) && (j <= player_x + r) && map[i][j] == wall) {
|
if ((player_y - r <= i) && (i <= player_y + r) && (player_x - r <= j) && (j <= player_x + r) && map[i][j] == wall) {
|
||||||
inventory[wall] += 1;
|
inventory[wall] += 1;
|
||||||
map[i][j] = empty;
|
map[i][j] = empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void midasHand(int m, int n) {
|
void midasHand(int m, int n) {
|
||||||
if (map[m][n] == wall) {
|
if (map[m][n] == wall) {
|
||||||
map[m][n] = gold;
|
map[m][n] = gold;
|
||||||
if (m > 0) midasHand(m - 1, n);
|
if (m > 0) midasHand(m - 1, n);
|
||||||
if (n > 0) midasHand(m, n - 1);
|
if (n > 0) midasHand(m, n - 1);
|
||||||
if (m < M - 1) midasHand(m + 1, n);
|
if (m < M - 1) midasHand(m + 1, n);
|
||||||
if (n < N - 1) midasHand(m, n + 1);
|
if (n < N - 1) midasHand(m, n + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doMidashand() {
|
void doMidashand() {
|
||||||
if ((player_y < M - 1) and map[player_y + 1][player_x] == wall) midasHand(player_y + 1, player_x);
|
if ((player_y < M - 1) and map[player_y + 1][player_x] == wall) midasHand(player_y + 1, player_x);
|
||||||
if ((player_x < N - 1) and map[player_y][player_x + 1] == wall) midasHand(player_y, player_x + 1);
|
if ((player_x < N - 1) and map[player_y][player_x + 1] == wall) midasHand(player_y, player_x + 1);
|
||||||
if ((player_y > 0) and map[player_y - 1][player_x] == wall) midasHand(player_y - 1, player_x);
|
if ((player_y > 0) and map[player_y - 1][player_x] == wall) midasHand(player_y - 1, player_x);
|
||||||
if ((player_x > 0) and map[player_y][player_x - 1] == wall) midasHand(player_y, player_x - 1);
|
if ((player_x > 0) and map[player_y][player_x - 1] == wall) midasHand(player_y, player_x - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool netToggle = false;
|
bool netToggle = false;
|
||||||
void drawNet() {
|
void drawNet() {
|
||||||
for (int i = 0; i <= N * WIDTH; i = i + WIDTH) {
|
for (int i = 0; i <= N * WIDTH; i = i + WIDTH) {
|
||||||
DrawLine(i, 0, i, M * HEIGHT, BLACK);
|
DrawLine(i, 0, i, M * HEIGHT, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= M * HEIGHT; i = i + HEIGHT) {
|
for (int i = 0; i <= M * HEIGHT; i = i + HEIGHT) {
|
||||||
DrawLine(0, i, N * WIDTH, i, BLACK);
|
DrawLine(0, i, N * WIDTH, i, BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMap() {
|
void drawMap() {
|
||||||
// Êîäû ÿ÷ååê:
|
// Êîäû ÿ÷ååê:
|
||||||
// 0 - ñâîáîäíà
|
// 0 - ñâîáîäíà
|
||||||
// 1 -
|
// 1 -
|
||||||
// 2 - ïðåïÿòñòâèå
|
// 2 - ïðåïÿòñòâèå
|
||||||
// 3 - çîëîòî
|
// 3 - çîëîòî
|
||||||
Color colors[4] = { LIGHTGRAY, PUREBLUE, BLACK, YELLOW };
|
Color colors[4] = { LIGHTGRAY, PUREBLUE, BLACK, YELLOW };
|
||||||
|
|
||||||
for (int i = 0; i < M; i++) {
|
for (int i = 0; i < M; i++) {
|
||||||
for (int j = 0; j < N; j++) {
|
for (int j = 0; j < N; j++) {
|
||||||
int x1 = j * WIDTH;
|
int x1 = j * WIDTH;
|
||||||
int y1 = i * HEIGHT;
|
int y1 = i * HEIGHT;
|
||||||
DrawRectangle(x1, y1, WIDTH, HEIGHT, colors[map[i][j]]);
|
DrawRectangle(x1, y1, WIDTH, HEIGHT, colors[map[i][j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPlayer() {
|
void drawPlayer() {
|
||||||
int x1 = player_x * WIDTH;
|
int x1 = player_x * WIDTH;
|
||||||
int y1 = player_y * HEIGHT;;
|
int y1 = player_y * HEIGHT;;
|
||||||
DrawRectangle(x1, y1, WIDTH, HEIGHT, PUREBLUE);
|
DrawRectangle(x1, y1, WIDTH, HEIGHT, PUREBLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawBottomBar(Font font, float fontSize) {
|
void drawBottomBar(Font font, float fontSize) {
|
||||||
DrawRectangle(0, HEIGHT * M, WIDTH * N, VOFFSET, BLACKGRAY);
|
DrawRectangle(0, HEIGHT * M, WIDTH * N, VOFFSET, BLACKGRAY);
|
||||||
|
|
||||||
static char gold_string[50];
|
static char gold_string[50];
|
||||||
static char wall_string[50];
|
static char wall_string[50];
|
||||||
|
|
||||||
static char help_string[] = "wasd - move player G - change item F5 - save\narrows - place item M - Midas hand F9 - load";
|
static char help_string[] = "wasd - move player G - change item F5 - save\narrows - place item M - Midas hand F9 - load";
|
||||||
|
|
||||||
sprintf(gold_string, " gold = %d", inventory[gold]);
|
sprintf(gold_string, " gold = %d", inventory[gold]);
|
||||||
sprintf(wall_string, " wall = %d", inventory[wall]);
|
sprintf(wall_string, " wall = %d", inventory[wall]);
|
||||||
|
|
||||||
if (selected_element == gold) gold_string[0] = '>';
|
if (selected_element == gold) gold_string[0] = '>';
|
||||||
else if (selected_element == wall) wall_string[0] = '>';
|
else if (selected_element == wall) wall_string[0] = '>';
|
||||||
|
|
||||||
Vector2 goldpos = { WIDTH / 4, HEIGHT * M };
|
Vector2 goldpos = { WIDTH / 4, HEIGHT * M };
|
||||||
Vector2 wallpos = { WIDTH / 4, HEIGHT * M + fontSize };
|
Vector2 wallpos = { WIDTH / 4, HEIGHT * M + fontSize };
|
||||||
Vector2 helppos = { WIDTH * N - 550 , HEIGHT * M };
|
Vector2 helppos = { WIDTH * N - 550 , HEIGHT * M };
|
||||||
|
|
||||||
DrawTextEx(font, gold_string, goldpos, fontSize, 0, VSGRAY);
|
DrawTextEx(font, gold_string, goldpos, fontSize, 0, VSGRAY);
|
||||||
DrawTextEx(font, wall_string, wallpos, fontSize, 0, VSGRAY);
|
DrawTextEx(font, wall_string, wallpos, fontSize, 0, VSGRAY);
|
||||||
DrawTextEx(font, help_string, helppos, fontSize, 0, VSGRAY);
|
DrawTextEx(font, help_string, helppos, fontSize, 0, VSGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void save() {
|
void save() {
|
||||||
FILE* fout = fopen("savefile.txt", "w");
|
FILE* fout = fopen("savefile.txt", "w");
|
||||||
if (fout == NULL) {
|
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,},
|
||||||
"Îøèáêà ñîõðàíåíèÿ",
|
"Îøèáêà ñîõðàíåíèÿ",
|
||||||
"Íåâîçìîæíî ñîçäàòü ôàéë",
|
"Íåâîçìîæíî ñîçäàòü ôàéë",
|
||||||
"Îê;Âûéòè");
|
"Îê;Âûéòè");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "%d %d\n", M, N);
|
fprintf(fout, "%d %d\n", M, N);
|
||||||
for (int i = 0; i < M; i++) {
|
for (int i = 0; i < M; i++) {
|
||||||
for (int j = 0; j < N; j++) {
|
for (int j = 0; j < N; j++) {
|
||||||
fprintf(fout, "%d ", map[i][j]);
|
fprintf(fout, "%d ", map[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
||||||
fprintf(fout, "%d ", inventory[i]);
|
fprintf(fout, "%d ", inventory[i]);
|
||||||
}
|
}
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
fprintf(fout, "%d %d %d\n", player_x, player_y, selected_element);
|
fprintf(fout, "%d %d %d\n", player_x, player_y, selected_element);
|
||||||
|
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
FILE* fin = fopen("savefile.txt", "r");
|
FILE* fin = fopen("savefile.txt", "r");
|
||||||
if (fin == NULL) {
|
if (fin == NULL) {
|
||||||
printf("error");
|
printf("error");
|
||||||
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, },
|
||||||
"Îøèáêà çàãðóçêè",
|
"Îøèáêà çàãðóçêè",
|
||||||
"Ôàéë íå íàéäåí\nÏîïðîáóéòå ñíà÷àëà ñîõðàíèòü èãðó",
|
"Ôàéë íå íàéäåí\nÏîïðîáóéòå ñíà÷àëà ñîõðàíèòü èãðó",
|
||||||
"Îê;Âûéòè");
|
"Îê;Âûéòè");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int m, n;
|
int m, n;
|
||||||
fscanf_s(fin, "%d%d", &m, &n);
|
fscanf_s(fin, "%d%d", &m, &n);
|
||||||
if (m != M || n != N) {
|
if (m != M || n != N) {
|
||||||
printf("error");
|
printf("error");
|
||||||
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, },
|
||||||
"Îøèáêà çàãðóçêè",
|
"Îøèáêà çàãðóçêè",
|
||||||
"Íåïðàâèëüíûé ðàçìåð êàðòû!\nÏðîâåðüòå öåëîñòíîñòü ñîõðàíåíèÿ",
|
"Íåïðàâèëüíûé ðàçìåð êàðòû!\nÏðîâåðüòå öåëîñòíîñòü ñîõðàíåíèÿ",
|
||||||
"Îê;Âûéòè");
|
"Îê;Âûéòè");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
fscanf_s(fin, "%d", &map[i][j]);
|
fscanf_s(fin, "%d", &map[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
||||||
fscanf_s(fin, "%d", &inventory[i]);
|
fscanf_s(fin, "%d", &inventory[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf_s(fin, "%d%d%d", &player_x, &player_y, &selected_element);
|
fscanf_s(fin, "%d%d%d", &player_x, &player_y, &selected_element);
|
||||||
|
|
||||||
fclose(fin);
|
fclose(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleKeys() {
|
void handleKeys() {
|
||||||
switch (GetKeyPressed())
|
switch (GetKeyPressed())
|
||||||
{
|
{
|
||||||
case KEY_F5:
|
case KEY_F5:
|
||||||
save();
|
save();
|
||||||
break;
|
break;
|
||||||
case KEY_F9:
|
case KEY_F9:
|
||||||
load();
|
load();
|
||||||
break;
|
break;
|
||||||
case KEY_SPACE:
|
case KEY_SPACE:
|
||||||
netToggle = !netToggle;
|
netToggle = !netToggle;
|
||||||
break;
|
break;
|
||||||
case KEY_W:
|
case KEY_W:
|
||||||
movePlayer(up);
|
movePlayer(up);
|
||||||
break;
|
break;
|
||||||
case KEY_S:
|
case KEY_S:
|
||||||
movePlayer(down);
|
movePlayer(down);
|
||||||
break;
|
break;
|
||||||
case KEY_D:
|
case KEY_D:
|
||||||
movePlayer(right);
|
movePlayer(right);
|
||||||
break;
|
break;
|
||||||
case KEY_A:
|
case KEY_A:
|
||||||
movePlayer(left);
|
movePlayer(left);
|
||||||
break;
|
break;
|
||||||
case KEY_ONE:
|
case KEY_ONE:
|
||||||
stomp(1);
|
stomp(1);
|
||||||
break;
|
break;
|
||||||
case KEY_TWO:
|
case KEY_TWO:
|
||||||
stomp(2);
|
stomp(2);
|
||||||
break;
|
break;
|
||||||
case KEY_Z:
|
case KEY_Z:
|
||||||
deathbeam(right);
|
deathbeam(right);
|
||||||
break;
|
break;
|
||||||
case KEY_M:
|
case KEY_M:
|
||||||
doMidashand();
|
doMidashand();
|
||||||
break;
|
break;
|
||||||
case KEY_G:
|
case KEY_G:
|
||||||
if (selected_element == gold) selected_element = wall;
|
if (selected_element == gold) selected_element = wall;
|
||||||
else selected_element = gold;
|
else selected_element = gold;
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
putElement(left, selected_element);
|
putElement(left, selected_element);
|
||||||
break;
|
break;
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
putElement(right, selected_element);
|
putElement(right, selected_element);
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
putElement(up, selected_element);
|
putElement(up, selected_element);
|
||||||
break;
|
break;
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
putElement(down, selected_element);
|
putElement(down, selected_element);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||||
|
|
||||||
InitWindow(N * WIDTH, M * HEIGHT + VOFFSET, "lab16 with raylib");
|
InitWindow(N * WIDTH, M * HEIGHT + VOFFSET, "lab16 with raylib");
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
SearchAndSetResourceDir("resources");
|
SearchAndSetResourceDir("resources");
|
||||||
|
|
||||||
//Font InconsolataRegular = LoadFontEx("Inconsolata-Regular.ttf", 24, NULL, 0);
|
//Font InconsolataRegular = LoadFontEx("Inconsolata-Regular.ttf", 24, NULL, 0);
|
||||||
Font InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, NULL, 0);
|
Font InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, NULL, 0);
|
||||||
SetTextureFilter(InconsolataSemiBold.texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(InconsolataSemiBold.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
//Font InconsolataBold = LoadFontEx("Inconsolata-Bold.ttf", 24, NULL, 0);
|
//Font InconsolataBold = LoadFontEx("Inconsolata-Bold.ttf", 24, NULL, 0);
|
||||||
|
|
||||||
// game loop
|
// game loop
|
||||||
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window
|
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window
|
||||||
{
|
{
|
||||||
handleKeys();
|
handleKeys();
|
||||||
|
|
||||||
// drawing
|
// drawing
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
// Setup the back buffer for drawing (clear color and depth buffers)
|
// Setup the back buffer for drawing (clear color and depth buffers)
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
|
|
||||||
drawMap();
|
drawMap();
|
||||||
drawPlayer();
|
drawPlayer();
|
||||||
drawBottomBar(InconsolataSemiBold, 24);
|
drawBottomBar(InconsolataSemiBold, 24);
|
||||||
|
|
||||||
if (netToggle) {
|
if (netToggle) {
|
||||||
drawNet();
|
drawNet();
|
||||||
}
|
}
|
||||||
|
|
||||||
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
//UnloadFont(InconsolataRegular);
|
//UnloadFont(InconsolataRegular);
|
||||||
UnloadFont(InconsolataSemiBold);
|
UnloadFont(InconsolataSemiBold);
|
||||||
//UnloadFont(InconsolataBold);
|
//UnloadFont(InconsolataBold);
|
||||||
|
|
||||||
// destroy the window and cleanup the OpenGL context
|
// destroy the window and cleanup the OpenGL context
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
1
raylib files/raylib.rc
Normal file
1
raylib files/raylib.rc
Normal file
@ -0,0 +1 @@
|
|||||||
|
GLFW_ICON ICON "..\\resources\\logo.ico"
|
Loading…
Reference in New Issue
Block a user