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_x = 1;
|
||||||
int player_y = 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
|
// 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 };
|
||||||
@ -65,16 +65,52 @@ typedef enum { 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) {
|
||||||
|
if (map[player_y][player_x - 1] != wall) {
|
||||||
|
player_x -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (map[player_y][N - 1] != wall) {
|
||||||
|
player_x = N - 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) {
|
||||||
|
if (map[player_y][player_x + 1] != wall) {
|
||||||
|
player_x += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (map[player_y][0] != wall) {
|
||||||
|
player_x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
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) {
|
||||||
|
if (map[player_y - 1][player_x] != wall) {
|
||||||
|
player_y -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (map[M - 1][player_x] != wall) {
|
||||||
|
player_y = M - 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) {
|
||||||
|
if (map[player_y + 1][player_x] != wall) {
|
||||||
|
player_y += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (map[0][player_x] != wall) {
|
||||||
|
player_y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (map[player_y][player_x] == gold) {
|
if (map[player_y][player_x] == gold) {
|
||||||
@ -465,7 +501,7 @@ void callNKErrorBoxes(struct nk_context* ctx) {
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||||
//SetConfigFlags(FLAG_MSAA_4X_HINT);
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
InitWindow(N * WIDTH, M * HEIGHT + VOFFSET, "lab16 with raylib");
|
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 InconsolataSemiBold = LoadFontEx("Inconsolata-SemiBold.ttf", 48, codepoints, 512);
|
||||||
Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 36, codepoints, CPSIZE);
|
Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 36, codepoints, CPSIZE);
|
||||||
SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
Font Consolas = LoadFontEx("consola.ttf", 24, codepoints, CPSIZE);
|
//Font Consolas = LoadFontEx("consola.ttf", 24, codepoints, CPSIZE);
|
||||||
SetTextureFilter(Consolas.texture, TEXTURE_FILTER_BILINEAR);
|
//SetTextureFilter(Consolas.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
//Font Arial = LoadFontEx("arial.ttf", 36, codepoints, CPSIZE);
|
//Font Arial = LoadFontEx("arial.ttf", 36, codepoints, CPSIZE);
|
||||||
//SetTextureFilter(Arial.texture, TEXTURE_FILTER_BILINEAR);
|
//SetTextureFilter(Arial.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
|
|
||||||
@ -505,6 +541,9 @@ int main()
|
|||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Update game logic
|
// Update game logic
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
printf("lol");
|
||||||
|
|
||||||
if (errorCode == OK)
|
if (errorCode == OK)
|
||||||
{
|
{
|
||||||
handleKeys();
|
handleKeys();
|
||||||
@ -543,7 +582,7 @@ int main()
|
|||||||
|
|
||||||
drawMap();
|
drawMap();
|
||||||
drawPlayer();
|
drawPlayer();
|
||||||
drawBottomBar(Consolas, 24);
|
drawBottomBar(InconsolataBold, 24);
|
||||||
|
|
||||||
if (editMap) {
|
if (editMap) {
|
||||||
Rectangle rec = {
|
Rectangle rec = {
|
||||||
@ -571,10 +610,14 @@ int main()
|
|||||||
// Render the Nuklear GUI
|
// Render the Nuklear GUI
|
||||||
//DrawNuklear(ctx);
|
//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
|
// show mouse position
|
||||||
//DrawText(TextFormat("%.1f %.1f", mousePos.x, mousePos.y), 5, M * HEIGHT - 30, 30, ORANGE);
|
//DrawText(TextFormat("%.1f %.1f", mousePos.x, mousePos.y), 5, M * HEIGHT - 30, 30, ORANGE);
|
||||||
@ -589,6 +632,7 @@ int main()
|
|||||||
|
|
||||||
//UnloadFont(InconsolataRegular);
|
//UnloadFont(InconsolataRegular);
|
||||||
UnloadFont(InconsolataBold);
|
UnloadFont(InconsolataBold);
|
||||||
|
//UnloadFont(Consolas);
|
||||||
//UnloadFont(Arial);
|
//UnloadFont(Arial);
|
||||||
//UnloadFont(InconsolataBold);
|
//UnloadFont(InconsolataBold);
|
||||||
|
|
||||||
|
@ -1,388 +1,388 @@
|
|||||||
// lab18.cpp : Определяет точку входа для приложения.
|
// lab18.cpp : Определяет точку входа для приложения.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
#include "lab18.h"
|
#include "lab18.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
#define MAX_LOADSTRING 100
|
||||||
|
|
||||||
// Глобальные переменные:
|
// Глобальные переменные:
|
||||||
HINSTANCE hInst; // текущий экземпляр
|
HINSTANCE hInst; // текущий экземпляр
|
||||||
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
||||||
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
||||||
|
|
||||||
// Отправить объявления функций, включенных в этот модуль кода:
|
// Отправить объявления функций, включенных в этот модуль кода:
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||||
BOOL InitInstance(HINSTANCE, int);
|
BOOL InitInstance(HINSTANCE, int);
|
||||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||||
_In_opt_ HINSTANCE hPrevInstance,
|
_In_opt_ HINSTANCE hPrevInstance,
|
||||||
_In_ LPWSTR lpCmdLine,
|
_In_ LPWSTR lpCmdLine,
|
||||||
_In_ int nCmdShow)
|
_In_ int nCmdShow)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
// TODO: Разместите код здесь.
|
// TODO: Разместите код здесь.
|
||||||
|
|
||||||
// Инициализация глобальных строк
|
// Инициализация глобальных строк
|
||||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||||
LoadStringW(hInstance, IDC_LAB18, szWindowClass, MAX_LOADSTRING);
|
LoadStringW(hInstance, IDC_LAB18, szWindowClass, MAX_LOADSTRING);
|
||||||
MyRegisterClass(hInstance);
|
MyRegisterClass(hInstance);
|
||||||
|
|
||||||
// Выполнить инициализацию приложения:
|
// Выполнить инициализацию приложения:
|
||||||
if (!InitInstance (hInstance, nCmdShow))
|
if (!InitInstance (hInstance, nCmdShow))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB18));
|
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB18));
|
||||||
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
// Цикл основного сообщения:
|
// Цикл основного сообщения:
|
||||||
while (GetMessage(&msg, nullptr, 0, 0))
|
while (GetMessage(&msg, nullptr, 0, 0))
|
||||||
{
|
{
|
||||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) msg.wParam;
|
return (int) msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// ФУНКЦИЯ: MyRegisterClass()
|
// ФУНКЦИЯ: MyRegisterClass()
|
||||||
//
|
//
|
||||||
// ЦЕЛЬ: Регистрирует класс окна.
|
// ЦЕЛЬ: Регистрирует класс окна.
|
||||||
//
|
//
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
WNDCLASSEXW wcex;
|
WNDCLASSEXW wcex;
|
||||||
|
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
|
||||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
wcex.lpfnWndProc = WndProc;
|
wcex.lpfnWndProc = WndProc;
|
||||||
wcex.cbClsExtra = 0;
|
wcex.cbClsExtra = 0;
|
||||||
wcex.cbWndExtra = 0;
|
wcex.cbWndExtra = 0;
|
||||||
wcex.hInstance = hInstance;
|
wcex.hInstance = hInstance;
|
||||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LAB18));
|
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LAB18));
|
||||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB18);
|
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB18);
|
||||||
wcex.lpszClassName = szWindowClass;
|
wcex.lpszClassName = szWindowClass;
|
||||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||||
|
|
||||||
return RegisterClassExW(&wcex);
|
return RegisterClassExW(&wcex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
||||||
//
|
//
|
||||||
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
||||||
//
|
//
|
||||||
// КОММЕНТАРИИ:
|
// КОММЕНТАРИИ:
|
||||||
//
|
//
|
||||||
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
||||||
// создается и выводится главное окно программы.
|
// создается и выводится главное окно программы.
|
||||||
//
|
//
|
||||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
{
|
{
|
||||||
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
||||||
|
|
||||||
HWND hWnd = CreateWindowExW(WS_EX_COMPOSITED, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
HWND hWnd = CreateWindowExW(WS_EX_COMPOSITED, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
||||||
|
|
||||||
if (!hWnd)
|
if (!hWnd)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(hWnd, nCmdShow);
|
ShowWindow(hWnd, nCmdShow);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool netToggle = true;
|
bool netToggle = true;
|
||||||
|
|
||||||
void drawNet(HDC hdc, int width, int height, int hstep, int vstep) {
|
void drawNet(HDC hdc, int width, int height, int hstep, int vstep) {
|
||||||
for (int i = 0; i <= width; i = i + hstep) {
|
for (int i = 0; i <= width; i = i + hstep) {
|
||||||
MoveToEx(hdc, i, 0, NULL);
|
MoveToEx(hdc, i, 0, NULL);
|
||||||
LineTo(hdc, i, height);
|
LineTo(hdc, i, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= height; i = i + vstep) {
|
for (int i = 0; i <= height; i = i + vstep) {
|
||||||
MoveToEx(hdc, 0, i, NULL);
|
MoveToEx(hdc, 0, i, NULL);
|
||||||
LineTo(hdc, width, i);
|
LineTo(hdc, width, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTriangle(HDC hdc, int cx, int cy, int size) {
|
void drawTriangle(HDC hdc, int cx, int cy, int size) {
|
||||||
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 201, 176));
|
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 201, 176));
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
|
|
||||||
POINT p[4] = {
|
POINT p[4] = {
|
||||||
cx, cy - size,
|
cx, cy - size,
|
||||||
cx + size, cy + size,
|
cx + size, cy + size,
|
||||||
cx - size, cy + size,
|
cx - size, cy + size,
|
||||||
cx, cy - size
|
cx, cy - size
|
||||||
};
|
};
|
||||||
Polyline(hdc, p, 4);
|
Polyline(hdc, p, 4);
|
||||||
|
|
||||||
DeleteObject(hPen);
|
DeleteObject(hPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHourglass(HDC hdc, int cx, int cy, int size) {
|
void drawHourglass(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, 200));
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
|
|
||||||
POINT p[5] = {
|
POINT p[5] = {
|
||||||
cx - size / 2, cy - size,
|
cx - size / 2, cy - size,
|
||||||
cx + size / 2, cy - size,
|
cx + size / 2, cy - size,
|
||||||
cx - size, cy + size,
|
cx - size, cy + size,
|
||||||
cx + size, cy + size,
|
cx + size, cy + size,
|
||||||
cx - size / 2, cy - size
|
cx - size / 2, cy - size
|
||||||
};
|
};
|
||||||
Polyline(hdc, p, 5);
|
Polyline(hdc, p, 5);
|
||||||
|
|
||||||
DeleteObject(hPen);
|
DeleteObject(hPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRomb(HDC hdc, int cx, int cy, int size) {
|
void drawRomb(HDC hdc, int cx, int cy, int size) {
|
||||||
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 201, 176));
|
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 201, 176));
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
|
|
||||||
POINT p[5] = {
|
POINT p[5] = {
|
||||||
cx, cy - size,
|
cx, cy - size,
|
||||||
cx + size, cy,
|
cx + size, cy,
|
||||||
cx, cy + size,
|
cx, cy + size,
|
||||||
cx - size, cy,
|
cx - size, cy,
|
||||||
cx, cy - size,
|
cx, cy - size,
|
||||||
};
|
};
|
||||||
Polyline(hdc, p, 5);
|
Polyline(hdc, p, 5);
|
||||||
|
|
||||||
DeleteObject(hPen);
|
DeleteObject(hPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawStar(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, 255));
|
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(78, 180, 255));
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
|
|
||||||
POINT p[9] = {
|
POINT p[9] = {
|
||||||
cx, cy - size,
|
cx, cy - size,
|
||||||
cx + size / 4, cy - size / 4,
|
cx + size / 4, cy - size / 4,
|
||||||
cx + size, cy,
|
cx + size, cy,
|
||||||
cx + size / 4, cy + size / 4,
|
cx + size / 4, cy + size / 4,
|
||||||
cx, cy + size,
|
cx, cy + size,
|
||||||
cx - size / 4, cy + size / 4,
|
cx - size / 4, cy + size / 4,
|
||||||
cx - size, cy,
|
cx - size, cy,
|
||||||
cx - size / 4, cy - size / 4,
|
cx - size / 4, cy - size / 4,
|
||||||
cx, cy - size
|
cx, cy - size
|
||||||
};
|
};
|
||||||
Polyline(hdc, p, 9);
|
Polyline(hdc, p, 9);
|
||||||
|
|
||||||
DeleteObject(hPen);
|
DeleteObject(hPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawCirle(HDC hdc, int cx, int cy, int size) {
|
void drawCirle(HDC hdc, int cx, int cy, int size) {
|
||||||
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(255, 0, 255));
|
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(255, 0, 255));
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
|
|
||||||
Ellipse(hdc, cx - size, cy - size, cx + size, cy + size);
|
Ellipse(hdc, cx - size, cy - size, cx + size, cy + size);
|
||||||
|
|
||||||
DeleteObject(hPen);
|
DeleteObject(hPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRecursiveTriangle(HDC hdc, int cx, int cy, int size, int mode) {
|
void drawRecursiveTriangle(HDC hdc, int cx, int cy, int size, int mode) {
|
||||||
drawTriangle(hdc, cx, cy, size);
|
drawTriangle(hdc, cx, cy, size);
|
||||||
|
|
||||||
if (size < 20) {
|
if (size < 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode > 0 && mode != 3) drawRecursiveTriangle(hdc, cx, cy - size, size / 2, mode);
|
if (mode > 0 && mode != 3) drawRecursiveTriangle(hdc, cx, cy - size, size / 2, mode);
|
||||||
if (mode > 1 && mode != 4) drawRecursiveTriangle(hdc, cx + size, cy + size, size / 2, mode);
|
if (mode > 1 && mode != 4) drawRecursiveTriangle(hdc, cx + size, cy + size, size / 2, mode);
|
||||||
if (mode > 2) drawRecursiveTriangle(hdc, cx - size, cy + size, size / 2, mode);
|
if (mode > 2) drawRecursiveTriangle(hdc, cx - size, cy + size, size / 2, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRecursiveHourglass(HDC hdc, int cx, int cy, int size, int mode) {
|
void drawRecursiveHourglass(HDC hdc, int cx, int cy, int size, int mode) {
|
||||||
drawHourglass(hdc, cx, cy, size);
|
drawHourglass(hdc, cx, cy, size);
|
||||||
if (size < 20) {
|
if (size < 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode >= 1 && mode < 4) drawRecursiveHourglass(hdc, cx - size / 2, cy - size, size / 2, mode);
|
if (mode >= 1 && mode < 4) drawRecursiveHourglass(hdc, cx - size / 2, cy - size, size / 2, mode);
|
||||||
if (mode >= 2 && mode < 4) drawRecursiveHourglass(hdc, cx + size / 2, cy - size, size / 2, mode);
|
if (mode >= 2 && mode < 4) drawRecursiveHourglass(hdc, cx + size / 2, cy - size, size / 2, mode);
|
||||||
if (mode >= 3 && mode < 5) {
|
if (mode >= 3 && mode < 5) {
|
||||||
drawRecursiveHourglass(hdc, cx - size, cy + size, size / 2, mode);
|
drawRecursiveHourglass(hdc, cx - size, cy + size, size / 2, mode);
|
||||||
drawRecursiveHourglass(hdc, cx + size, cy + size, size / 2, mode);
|
drawRecursiveHourglass(hdc, cx + size, cy + size, size / 2, mode);
|
||||||
}
|
}
|
||||||
if (mode == 5 || mode == 7) drawRecursiveHourglass(hdc, cx - size, cy, size / 2, mode);
|
if (mode == 5 || mode == 7) drawRecursiveHourglass(hdc, cx - size, cy, size / 2, mode);
|
||||||
if (mode == 6 || mode == 7) drawRecursiveHourglass(hdc, cx + size, cy, size / 2, mode);
|
if (mode == 6 || mode == 7) drawRecursiveHourglass(hdc, cx + size, cy, size / 2, mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRecursiveRomb(HDC hdc, int cx, int cy, int size, int mode) {
|
void drawRecursiveRomb(HDC hdc, int cx, int cy, int size, int mode) {
|
||||||
drawRomb(hdc, cx, cy, size);
|
drawRomb(hdc, cx, cy, size);
|
||||||
if (size < 20) {
|
if (size < 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drawRecursiveRomb(hdc, cx - size, cy, size / 2, mode);
|
drawRecursiveRomb(hdc, cx - size, cy, size / 2, mode);
|
||||||
drawRecursiveRomb(hdc, cx + size, cy, size / 2, mode);
|
drawRecursiveRomb(hdc, cx + size, cy, size / 2, mode);
|
||||||
if (mode == 1 || mode == 3) drawRecursiveRomb(hdc, cx, cy + size, size / 2, mode);
|
if (mode == 1 || mode == 3) drawRecursiveRomb(hdc, cx, cy + size, size / 2, mode);
|
||||||
if (mode == 2 || mode == 3) drawRecursiveRomb(hdc, cx, cy - size, size / 2, mode);
|
if (mode == 2 || mode == 3) drawRecursiveRomb(hdc, cx, cy - size, size / 2, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRecursiveStar(HDC hdc, int cx, int cy, int size, int mode) {
|
void drawRecursiveStar(HDC hdc, int cx, int cy, int size, int mode) {
|
||||||
drawStar(hdc, cx, cy, size);
|
drawStar(hdc, cx, cy, size);
|
||||||
if (size < 20) {
|
if (size < 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode == 0 || mode == 2) drawRecursiveStar(hdc, cx - size, cy, 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 == 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);
|
||||||
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;
|
int circlecount = 0;
|
||||||
void drawRecursiveCircle(HDC hdc, int cx, int cy, int size, int i) {
|
void drawRecursiveCircle(HDC hdc, int cx, int cy, int size, int i) {
|
||||||
drawCirle(hdc, cx, cy, size);
|
drawCirle(hdc, cx, cy, size);
|
||||||
i--;
|
i--;
|
||||||
circlecount++;
|
circlecount++;
|
||||||
|
|
||||||
static HFONT hFont = CreateFontW(18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
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"));
|
OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH, TEXT("Consolas"));
|
||||||
|
|
||||||
SelectObject(hdc, hFont);
|
SelectObject(hdc, hFont);
|
||||||
SetTextColor(hdc, RGB(0, 0, 0));
|
SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
static char circle_string[10];
|
static char circle_string[10];
|
||||||
sprintf_s(circle_string, "%d", circlecount);
|
sprintf_s(circle_string, "%d", circlecount);
|
||||||
RECT circlerect = { cx - size, cy - size, cx + size, cy + size };
|
RECT circlerect = { cx - size, cy - size, cx + size, cy + size };
|
||||||
|
|
||||||
DrawTextA(hdc, circle_string, -1, &circlerect, (DT_SINGLELINE | DT_VCENTER | DT_CENTER));
|
DrawTextA(hdc, circle_string, -1, &circlerect, (DT_SINGLELINE | DT_VCENTER | DT_CENTER));
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawRecursiveCircle(hdc, cx, cy - size, size / 2, i);
|
drawRecursiveCircle(hdc, cx, cy - size, size / 2, i);
|
||||||
drawRecursiveCircle(hdc, cx + size, cy, size / 2, i);
|
drawRecursiveCircle(hdc, cx + size, cy, size / 2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trmode = 0;
|
int trmode = 0;
|
||||||
int hgmode = 0;
|
int hgmode = 0;
|
||||||
int rbmode = 0;
|
int rbmode = 0;
|
||||||
int imageVar = 0;
|
int imageVar = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||||
//
|
//
|
||||||
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
||||||
//
|
//
|
||||||
// WM_COMMAND - обработать меню приложения
|
// WM_COMMAND - обработать меню приложения
|
||||||
// WM_PAINT - Отрисовка главного окна
|
// WM_PAINT - Отрисовка главного окна
|
||||||
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
int wmId = LOWORD(wParam);
|
int wmId = LOWORD(wParam);
|
||||||
// Разобрать выбор в меню:
|
// Разобрать выбор в меню:
|
||||||
switch (wmId)
|
switch (wmId)
|
||||||
{
|
{
|
||||||
case IDM_ABOUT:
|
case IDM_ABOUT:
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||||
break;
|
break;
|
||||||
case IDM_EXIT:
|
case IDM_EXIT:
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hWnd, &ps);
|
HDC hdc = BeginPaint(hWnd, &ps);
|
||||||
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(hWnd, &rect);
|
GetClientRect(hWnd, &rect);
|
||||||
|
|
||||||
if (netToggle) drawNet(hdc, rect.right, rect.bottom, 50, 50);
|
if (netToggle) drawNet(hdc, rect.right, rect.bottom, 50, 50);
|
||||||
|
|
||||||
drawRecursiveTriangle(hdc, 300, 300, 100, trmode);
|
drawRecursiveTriangle(hdc, 300, 300, 100, trmode);
|
||||||
drawRecursiveHourglass(hdc, 700, 300, 100, hgmode);
|
drawRecursiveHourglass(hdc, 700, 300, 100, hgmode);
|
||||||
|
|
||||||
drawRecursiveRomb(hdc, 300, 700, 100, rbmode);
|
drawRecursiveRomb(hdc, 300, 700, 100, rbmode);
|
||||||
drawRecursiveStar(hdc, 1100, 300, 100, rbmode);
|
drawRecursiveStar(hdc, 1100, 300, 100, rbmode);
|
||||||
|
|
||||||
drawRecursiveCircle(hdc, 1300, 700, 200, 5);
|
drawRecursiveCircle(hdc, 1300, 700, 200, 5);
|
||||||
circlecount = 0;
|
circlecount = 0;
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case VK_SPACE:
|
case VK_SPACE:
|
||||||
netToggle = !netToggle;
|
netToggle = !netToggle;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trmode++;
|
trmode++;
|
||||||
hgmode++;
|
hgmode++;
|
||||||
rbmode++;
|
rbmode++;
|
||||||
if (trmode > 5) trmode = 0;
|
if (trmode > 5) trmode = 0;
|
||||||
if (hgmode > 7) hgmode = 0;
|
if (hgmode > 7) hgmode = 0;
|
||||||
if (rbmode > 3) rbmode = 0;
|
if (rbmode > 3) rbmode = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
InvalidateRect(hWnd, NULL, TRUE);
|
InvalidateRect(hWnd, NULL, TRUE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обработчик сообщений для окна "О программе".
|
// Обработчик сообщений для окна "О программе".
|
||||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
{
|
{
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (INT_PTR)FALSE;
|
return (INT_PTR)FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user