mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-18 08:39:11 +04:00
игра жизнь начало
This commit is contained in:
parent
a7e778640f
commit
92e2fbf7e9
28
Game of Life/Game of Life.sln
Normal file
28
Game of Life/Game of Life.sln
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game of Life", "Game of Life\Game of Life.vcxproj", "{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Debug|x64.Build.0 = Debug|x64
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Release|x64.ActiveCfg = Release|x64
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Release|x64.Build.0 = Release|x64
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{743E4B45-9B39-4BC5-939A-C9CF6C0B295B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
144
Game of Life/Game of Life/Game of Life.vcxproj
Normal file
144
Game of Life/Game of Life/Game of Life.vcxproj
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{743e4b45-9b39-4bc5-939a-c9cf6c0b295b}</ProjectGuid>
|
||||
<RootNamespace>GameofLife</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;winmm.lib;opengl32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;winmm.lib;opengl32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\raylib.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
27
Game of Life/Game of Life/Game of Life.vcxproj.filters
Normal file
27
Game of Life/Game of Life/Game of Life.vcxproj.filters
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\raylib.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
1708
Game of Life/include/raylib.h
Normal file
1708
Game of Life/include/raylib.h
Normal file
File diff suppressed because it is too large
Load Diff
2941
Game of Life/include/raymath.h
Normal file
2941
Game of Life/include/raymath.h
Normal file
File diff suppressed because it is too large
Load Diff
5262
Game of Life/include/rlgl.h
Normal file
5262
Game of Life/include/rlgl.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Game of Life/lib/raylib.lib
Normal file
BIN
Game of Life/lib/raylib.lib
Normal file
Binary file not shown.
BIN
Game of Life/resources/Inconsolata-LGC-Bold.ttf
Normal file
BIN
Game of Life/resources/Inconsolata-LGC-Bold.ttf
Normal file
Binary file not shown.
BIN
Game of Life/resources/Inconsolata-LGC.ttf
Normal file
BIN
Game of Life/resources/Inconsolata-LGC.ttf
Normal file
Binary file not shown.
35
Game of Life/src/main.c
Normal file
35
Game of Life/src/main.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include "raylib.h"
|
||||
#include <stdbool.h>
|
||||
#include <iso646.h>
|
||||
|
||||
|
||||
#define MAP_X 20
|
||||
#define MAP_Y 20
|
||||
|
||||
static bool map[MAP_X][MAP_Y] = { 0 };
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
@ -55,7 +55,7 @@ int map[M][N] = {
|
||||
int player_x = 1;
|
||||
int player_y = 1;
|
||||
|
||||
typedef 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
|
||||
#define INVENTORY_SIZE 4
|
||||
int inventory[INVENTORY_SIZE] = { 0, 0, 15, 0 };
|
||||
@ -65,16 +65,52 @@ typedef enum { left, right, up, down } enum_ways;
|
||||
void movePlayer(enum_ways move) {
|
||||
switch (move) {
|
||||
case left:
|
||||
if ((player_x > 0) and map[player_y][player_x - 1] != wall) player_x -= 1;
|
||||
if (player_x > 0) {
|
||||
if (map[player_y][player_x - 1] != wall) {
|
||||
player_x -= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (map[player_y][N - 1] != wall) {
|
||||
player_x = N - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case right:
|
||||
if ((player_x < N - 1) and map[player_y][player_x + 1] != wall) player_x += 1;
|
||||
if (player_x < N - 1) {
|
||||
if (map[player_y][player_x + 1] != wall) {
|
||||
player_x += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (map[player_y][0] != wall) {
|
||||
player_x = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case up:
|
||||
if ((player_y > 0) and map[player_y - 1][player_x] != wall) player_y -= 1;
|
||||
if (player_y > 0) {
|
||||
if (map[player_y - 1][player_x] != wall) {
|
||||
player_y -= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (map[M - 1][player_x] != wall) {
|
||||
player_y = M - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case down:
|
||||
if ((player_y < M - 1) and map[player_y + 1][player_x] != wall) player_y += 1;
|
||||
if (player_y < M - 1) {
|
||||
if (map[player_y + 1][player_x] != wall) {
|
||||
player_y += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (map[0][player_x] != wall) {
|
||||
player_y = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (map[player_y][player_x] == gold) {
|
||||
@ -465,7 +501,7 @@ void callNKErrorBoxes(struct nk_context* ctx) {
|
||||
int main()
|
||||
{
|
||||
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||
//SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
InitWindow(N * WIDTH, M * HEIGHT + VOFFSET, "lab16 with raylib");
|
||||
|
||||
@ -481,8 +517,8 @@ int main()
|
||||
//Font InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, codepoints, 512);
|
||||
Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 36, codepoints, CPSIZE);
|
||||
SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR);
|
||||
Font Consolas = LoadFontEx("consola.ttf", 24, codepoints, CPSIZE);
|
||||
SetTextureFilter(Consolas.texture, TEXTURE_FILTER_BILINEAR);
|
||||
//Font Consolas = LoadFontEx("consola.ttf", 24, codepoints, CPSIZE);
|
||||
//SetTextureFilter(Consolas.texture, TEXTURE_FILTER_BILINEAR);
|
||||
//Font Arial = LoadFontEx("arial.ttf", 36, codepoints, CPSIZE);
|
||||
//SetTextureFilter(Arial.texture, TEXTURE_FILTER_BILINEAR);
|
||||
|
||||
@ -505,6 +541,9 @@ int main()
|
||||
//------------------------------------------------------------------
|
||||
// Update game logic
|
||||
//------------------------------------------------------------------
|
||||
|
||||
printf("lol");
|
||||
|
||||
if (errorCode == OK)
|
||||
{
|
||||
handleKeys();
|
||||
@ -543,7 +582,7 @@ int main()
|
||||
|
||||
drawMap();
|
||||
drawPlayer();
|
||||
drawBottomBar(Consolas, 24);
|
||||
drawBottomBar(InconsolataBold, 24);
|
||||
|
||||
if (editMap) {
|
||||
Rectangle rec = {
|
||||
@ -571,10 +610,14 @@ int main()
|
||||
// Render the Nuklear GUI
|
||||
//DrawNuklear(ctx);
|
||||
|
||||
//drawRayguiErrorBoxes();
|
||||
drawRayguiErrorBoxes();
|
||||
}
|
||||
|
||||
DrawTextEx(Consolas, u8"Файл не найден\nПопробуйте сначала сохранить игру", (Vector2) { 100, 100 }, 24, 0, BLACK);
|
||||
Rectangle roundRect = { 100, 250, 185, 36 };
|
||||
DrawRectangleRounded(roundRect, 0.5f, 6, BLACK);
|
||||
DrawRectangleRoundedLines(roundRect, 0.5f, 6, ORANGE);
|
||||
|
||||
//DrawTextEx(Consolas, u8"Файл не найден\nПопробуйте сначала сохранить игру", (Vector2) { 100, 100 }, 24, 0, BLACK);
|
||||
|
||||
// show mouse position
|
||||
//DrawText(TextFormat("%.1f %.1f", mousePos.x, mousePos.y), 5, M * HEIGHT - 30, 30, ORANGE);
|
||||
@ -589,6 +632,7 @@ int main()
|
||||
|
||||
//UnloadFont(InconsolataRegular);
|
||||
UnloadFont(InconsolataBold);
|
||||
//UnloadFont(Consolas);
|
||||
//UnloadFont(Arial);
|
||||
//UnloadFont(InconsolataBold);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user