mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-18 08:39:11 +04:00
lab16 with raylib
This commit is contained in:
parent
b137f047cd
commit
b7ccb8ad21
5759
lab16 with raylib/include/raygui.h
Normal file
5759
lab16 with raylib/include/raygui.h
Normal file
File diff suppressed because it is too large
Load Diff
1708
lab16 with raylib/include/raylib.h
Normal file
1708
lab16 with raylib/include/raylib.h
Normal file
File diff suppressed because it is too large
Load Diff
2941
lab16 with raylib/include/raymath.h
Normal file
2941
lab16 with raylib/include/raymath.h
Normal file
File diff suppressed because it is too large
Load Diff
95
lab16 with raylib/include/resource_dir.h
Normal file
95
lab16 with raylib/include/resource_dir.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* raylibExtras * Utilities and Shared Components for Raylib
|
||||
*
|
||||
* Resource Dir * function to help find resource dir in common locations
|
||||
*
|
||||
* LICENSE: MIT
|
||||
*
|
||||
* Copyright (c) 2022 Jeffery Myers
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Looks for the specified resource dir in several common locations
|
||||
/// The working dir
|
||||
/// The app dir
|
||||
/// Up to 3 levels above the app dir
|
||||
/// When found the dir will be set as the working dir so that assets can be loaded relative to that.
|
||||
/// </summary>
|
||||
/// <param name="folderName">The name of the resources dir to look for</param>
|
||||
/// <returns>True if a dir with the name was found, false if no change was made to the working dir</returns>
|
||||
inline static bool SearchAndSetResourceDir(const char* folderName)
|
||||
{
|
||||
// check the working dir
|
||||
if (DirectoryExists(folderName))
|
||||
{
|
||||
ChangeDirectory(TextFormat("%s/%s", GetWorkingDirectory(), folderName));
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* appDir = GetApplicationDirectory();
|
||||
|
||||
// check the applicationDir
|
||||
const char* dir = TextFormat("%s%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check one up from the app dir
|
||||
dir = TextFormat("%s../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check two up from the app dir
|
||||
dir = TextFormat("%s../../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check three up from the app dir
|
||||
dir = TextFormat("%s../../../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
5262
lab16 with raylib/include/rlgl.h
Normal file
5262
lab16 with raylib/include/rlgl.h
Normal file
File diff suppressed because it is too large
Load Diff
28
lab16 with raylib/lab16 with raylib.sln
Normal file
28
lab16 with raylib/lab16 with raylib.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}") = "lab16 with raylib", "lab16 with raylib\lab16 with raylib.vcxproj", "{F46C61FA-6EB3-4701-B943-A20855C5F9EF}"
|
||||
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
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Debug|x64.Build.0 = Debug|x64
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Release|x64.ActiveCfg = Release|x64
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Release|x64.Build.0 = Release|x64
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F46C61FA-6EB3-4701-B943-A20855C5F9EF}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
147
lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj
Normal file
147
lab16 with raylib/lab16 with raylib/lab16 with raylib.vcxproj
Normal file
@ -0,0 +1,147 @@
|
||||
<?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>{f46c61fa-6eb3-4701-b943-a20855c5f9ef}</ProjectGuid>
|
||||
<RootNamespace>lab16withraylib</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;$(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;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\raygui.h" />
|
||||
<ClInclude Include="..\include\raylib.h" />
|
||||
<ClInclude Include="..\include\raymath.h" />
|
||||
<ClInclude Include="..\include\resource_dir.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,36 @@
|
||||
<?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>
|
||||
<ClInclude Include="..\include\raymath.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\raygui.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\resource_dir.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
BIN
lab16 with raylib/lib/raylib.dll
Normal file
BIN
lab16 with raylib/lib/raylib.dll
Normal file
Binary file not shown.
BIN
lab16 with raylib/lib/raylib.lib
Normal file
BIN
lab16 with raylib/lib/raylib.lib
Normal file
Binary file not shown.
BIN
lab16 with raylib/lib/raylibdll.lib
Normal file
BIN
lab16 with raylib/lib/raylibdll.lib
Normal file
Binary file not shown.
BIN
lab16 with raylib/resources/Inconsolata-Bold.ttf
Normal file
BIN
lab16 with raylib/resources/Inconsolata-Bold.ttf
Normal file
Binary file not shown.
BIN
lab16 with raylib/resources/Inconsolata-Medium.ttf
Normal file
BIN
lab16 with raylib/resources/Inconsolata-Medium.ttf
Normal file
Binary file not shown.
BIN
lab16 with raylib/resources/Inconsolata-Regular.ttf
Normal file
BIN
lab16 with raylib/resources/Inconsolata-Regular.ttf
Normal file
Binary file not shown.
BIN
lab16 with raylib/resources/Inconsolata-SemiBold.ttf
Normal file
BIN
lab16 with raylib/resources/Inconsolata-SemiBold.ttf
Normal file
Binary file not shown.
13
lab16 with raylib/resources/savefile.txt
Normal file
13
lab16 with raylib/resources/savefile.txt
Normal file
@ -0,0 +1,13 @@
|
||||
10 55
|
||||
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
|
356
lab16 with raylib/src/main.c
Normal file
356
lab16 with raylib/src/main.c
Normal file
@ -0,0 +1,356 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <stdio.h>
|
||||
#include <iso646.h>
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h"
|
||||
|
||||
#include "resource_dir.h"
|
||||
|
||||
#define M 10
|
||||
#define N 15
|
||||
#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 - ñâîáîäíà
|
||||
// 1 -
|
||||
// 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},
|
||||
{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, 0, 0, 0, 3, 0, 0, 0, 3, 3, 0, 0, 0},
|
||||
|
||||
{0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 0, 2, 0},
|
||||
{0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
int player_x = 1;
|
||||
int player_y = 1;
|
||||
|
||||
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 };
|
||||
obj_enum selected_element = gold;
|
||||
|
||||
typedef enum enum_ways { 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;
|
||||
break;
|
||||
case right:
|
||||
if ((player_x < N - 1) and map[player_y][player_x + 1] != wall) player_x += 1;
|
||||
break;
|
||||
case up:
|
||||
if ((player_y > 0) and map[player_y - 1][player_x] != wall) player_y -= 1;
|
||||
break;
|
||||
case down:
|
||||
if ((player_y < M - 1) and map[player_y + 1][player_x] != wall) player_y += 1;
|
||||
break;
|
||||
}
|
||||
if (map[player_y][player_x] == gold) {
|
||||
map[player_y][player_x] = empty;
|
||||
inventory[gold]++;
|
||||
}
|
||||
}
|
||||
|
||||
void putElement(enum_ways way, obj_enum element) {
|
||||
if (element != empty && inventory[element] == 0) return;
|
||||
|
||||
switch (way) {
|
||||
case left:
|
||||
if ((player_x > 0) and map[player_y][player_x - 1] == 0) {
|
||||
map[player_y][player_x - 1] = element;
|
||||
inventory[element]--;
|
||||
}
|
||||
break;
|
||||
case right:
|
||||
if ((player_x < N - 1) and map[player_y][player_x + 1] == 0) {
|
||||
map[player_y][player_x + 1] = element;
|
||||
inventory[element]--;
|
||||
}
|
||||
break;
|
||||
case up:
|
||||
if ((player_y > 0) and map[player_y - 1][player_x] == 0) {
|
||||
map[player_y - 1][player_x] = element;
|
||||
inventory[element]--;
|
||||
}
|
||||
break;
|
||||
case down:
|
||||
if ((player_y < M - 1) and map[player_y + 1][player_x] == 0) {
|
||||
map[player_y + 1][player_x] = element;
|
||||
inventory[element]--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void deathbeam(enum_ways way) {
|
||||
for (int i = player_x + 1; i < N; i++) {
|
||||
if (map[player_y][i] != empty) inventory[map[player_y][i]] += 1;
|
||||
map[player_y][i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void stomp(int r) {
|
||||
for (int i = 0; i < M; i++) {
|
||||
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) {
|
||||
inventory[wall] += 1;
|
||||
map[i][j] = empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void midasHand(int m, int n) {
|
||||
if (map[m][n] == wall) {
|
||||
map[m][n] = gold;
|
||||
if (m > 0) midasHand(m - 1, n);
|
||||
if (n > 0) midasHand(m, n - 1);
|
||||
if (m < M - 1) midasHand(m + 1, n);
|
||||
if (n < N - 1) midasHand(m, n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void doMidashand() {
|
||||
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_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);
|
||||
}
|
||||
|
||||
bool netToggle = false;
|
||||
void drawNet() {
|
||||
for (int i = 0; i <= N * WIDTH; i = i + WIDTH) {
|
||||
DrawLine(i, 0, i, M * HEIGHT, BLACK);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= M * HEIGHT; i = i + HEIGHT) {
|
||||
DrawLine(0, i, N * WIDTH, i, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
void drawMap() {
|
||||
// Êîäû ÿ÷ååê:
|
||||
// 0 - ñâîáîäíà
|
||||
// 1 -
|
||||
// 2 - ïðåïÿòñòâèå
|
||||
// 3 - çîëîòî
|
||||
Color colors[4] = { LIGHTGRAY, PUREBLUE, BLACK, YELLOW };
|
||||
|
||||
for (int i = 0; i < M; i++) {
|
||||
for (int j = 0; j < N; j++) {
|
||||
int x1 = j * WIDTH;
|
||||
int y1 = i * HEIGHT;
|
||||
DrawRectangle(x1, y1, WIDTH, HEIGHT, colors[map[i][j]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawPlayer() {
|
||||
int x1 = player_x * WIDTH;
|
||||
int y1 = player_y * HEIGHT;;
|
||||
DrawRectangle(x1, y1, WIDTH, HEIGHT, PUREBLUE);
|
||||
}
|
||||
|
||||
void drawBottomBar(Font font, float fontSize) {
|
||||
DrawRectangle(0, HEIGHT * M, WIDTH * N, VOFFSET, BLACKGRAY);
|
||||
|
||||
static char gold_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";
|
||||
|
||||
sprintf(gold_string, " gold = %d", inventory[gold]);
|
||||
sprintf(wall_string, " wall = %d", inventory[wall]);
|
||||
|
||||
if (selected_element == gold) gold_string[0] = '>';
|
||||
else if (selected_element == wall) wall_string[0] = '>';
|
||||
|
||||
Vector2 goldpos = { WIDTH / 4, HEIGHT * M };
|
||||
Vector2 wallpos = { WIDTH / 4, HEIGHT * M + fontSize };
|
||||
Vector2 helppos = { WIDTH * N - 550 , HEIGHT * M };
|
||||
|
||||
DrawTextEx(font, gold_string, goldpos, fontSize, 0, VSGRAY);
|
||||
DrawTextEx(font, wall_string, wallpos, fontSize, 0, VSGRAY);
|
||||
DrawTextEx(font, help_string, helppos, fontSize, 0, VSGRAY);
|
||||
}
|
||||
|
||||
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,},
|
||||
"Îøèáêà ñîõðàíåíèÿ",
|
||||
"Íåâîçìîæíî ñîçäàòü ôàéë",
|
||||
"Îê;Âûéòè");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(fout, "%d %d\n", M, N);
|
||||
for (int i = 0; i < M; i++) {
|
||||
for (int j = 0; j < N; j++) {
|
||||
fprintf(fout, "%d ", map[i][j]);
|
||||
}
|
||||
fprintf(fout, "\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
||||
fprintf(fout, "%d ", inventory[i]);
|
||||
}
|
||||
fprintf(fout, "\n");
|
||||
|
||||
fprintf(fout, "%d %d %d\n", player_x, player_y, selected_element);
|
||||
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
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Ïîïðîáóéòå ñíà÷àëà ñîõðàíèòü èãðó",
|
||||
"Îê;Âûéòè");
|
||||
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Ïðîâåðüòå öåëîñòíîñòü ñîõðàíåíèÿ",
|
||||
"Îê;Âûéòè");
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
fscanf_s(fin, "%d", &map[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < INVENTORY_SIZE; i++) {
|
||||
fscanf_s(fin, "%d", &inventory[i]);
|
||||
}
|
||||
|
||||
fscanf_s(fin, "%d%d%d", &player_x, &player_y, &selected_element);
|
||||
|
||||
fclose(fin);
|
||||
}
|
||||
|
||||
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 main() {
|
||||
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||
|
||||
InitWindow(N * WIDTH, M * HEIGHT + VOFFSET, "lab16 with raylib");
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
SearchAndSetResourceDir("resources");
|
||||
|
||||
//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);
|
||||
|
||||
// game loop
|
||||
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window
|
||||
{
|
||||
handleKeys();
|
||||
|
||||
// drawing
|
||||
BeginDrawing();
|
||||
|
||||
// Setup the back buffer for drawing (clear color and depth buffers)
|
||||
ClearBackground(WHITE);
|
||||
|
||||
drawMap();
|
||||
drawPlayer();
|
||||
drawBottomBar(InconsolataSemiBold, 24);
|
||||
|
||||
if (netToggle) {
|
||||
drawNet();
|
||||
}
|
||||
|
||||
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
//UnloadFont(InconsolataRegular);
|
||||
UnloadFont(InconsolataSemiBold);
|
||||
//UnloadFont(InconsolataBold);
|
||||
|
||||
// destroy the window and cleanup the OpenGL context
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,151 +1,155 @@
|
||||
<?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>{858481bd-1d6a-4285-8320-0f35abd843ec}</ProjectGuid>
|
||||
<RootNamespace>lab16</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="lab16.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab16.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab16.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="lab16.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="savefile.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?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>{858481bd-1d6a-4285-8320-0f35abd843ec}</ProjectGuid>
|
||||
<RootNamespace>lab16</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="lab16.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab16.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab16.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="lab16.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="savefile.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
5759
raylib files/raygui.h
Normal file
5759
raylib files/raygui.h
Normal file
File diff suppressed because it is too large
Load Diff
2599
raylib files/raylib-5.5_win64_msvc16/CHANGELOG
Normal file
2599
raylib files/raylib-5.5_win64_msvc16/CHANGELOG
Normal file
File diff suppressed because it is too large
Load Diff
16
raylib files/raylib-5.5_win64_msvc16/LICENSE
Normal file
16
raylib files/raylib-5.5_win64_msvc16/LICENSE
Normal file
@ -0,0 +1,16 @@
|
||||
Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
|
||||
|
||||
This software is provided "as-is", without any express or implied warranty. In no event
|
||||
will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
wrote the original software. If you use this software in a product, an acknowledgment
|
||||
in the product documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
150
raylib files/raylib-5.5_win64_msvc16/README.md
Normal file
150
raylib files/raylib-5.5_win64_msvc16/README.md
Normal file
@ -0,0 +1,150 @@
|
||||
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||
|
||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||
|
||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||
|
||||
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
[![GitHub Releases Downloads](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases)
|
||||
[![GitHub Stars](https://img.shields.io/github/stars/raysan5/raylib?style=flat&label=stars)](https://github.com/raysan5/raylib/stargazers)
|
||||
[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/5.0)](https://github.com/raysan5/raylib/commits/master)
|
||||
[![GitHub Sponsors](https://img.shields.io/github/sponsors/raysan5?label=sponsors)](https://github.com/sponsors/raysan5)
|
||||
[![Packaging Status](https://repology.org/badge/tiny-repos/raylib.svg)](https://repology.org/project/raylib/versions)
|
||||
[![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE)
|
||||
|
||||
[![Discord Members](https://img.shields.io/discord/426912293134270465.svg?label=Discord&logo=discord)](https://discord.gg/raylib)
|
||||
[![Reddit Static Badge](https://img.shields.io/badge/-r%2Fraylib-red?style=flat&logo=reddit&label=reddit)](https://www.reddit.com/r/raylib/)
|
||||
[![Youtube Subscribers](https://img.shields.io/youtube/channel/subscribers/UC8WIBkhYb5sBNqXO1mZ7WSQ?style=flat&label=Youtube&logo=youtube)](https://www.youtube.com/c/raylib)
|
||||
[![Twitch Status](https://img.shields.io/twitch/status/raysan5?style=flat&label=Twitch&logo=twitch)](https://www.twitch.tv/raysan5)
|
||||
|
||||
[![Windows](https://github.com/raysan5/raylib/workflows/Windows/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
|
||||
[![Linux](https://github.com/raysan5/raylib/workflows/Linux/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
|
||||
[![macOS](https://github.com/raysan5/raylib/workflows/macOS/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
|
||||
[![WebAssembly](https://github.com/raysan5/raylib/workflows/WebAssembly/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
|
||||
|
||||
[![CMakeBuilds](https://github.com/raysan5/raylib/workflows/CMakeBuilds/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
|
||||
[![Windows Examples](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
|
||||
[![Linux Examples](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0**)
|
||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||
- Multiple **Fonts** formats supported (TTF, OTF, FNT, BDF, sprite fonts)
|
||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, M3D, glTF)
|
||||
- Shaders support, including model shaders and **postprocessing** shaders
|
||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
- Audio loading and playing with streaming support (WAV, QOA, OGG, MP3, FLAC, XM, MOD)
|
||||
- **VR stereo rendering** support with configurable HMD device parameters
|
||||
- Huge examples collection with [+140 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**
|
||||
|
||||
basic example
|
||||
--------------
|
||||
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
```c
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
InitWindow(800, 450, "raylib [core] example - basic window");
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||
|
||||
raylib is also available via multiple package managers on multiple OS distributions.
|
||||
|
||||
#### Installing and building raylib on multiple platforms
|
||||
|
||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
||||
|
||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
||||
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
|
||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
||||
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
||||
|
||||
*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.*
|
||||
|
||||
#### Setup raylib with multiple IDEs
|
||||
|
||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
|
||||
|
||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||
|
||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.*
|
||||
|
||||
learning and docs
|
||||
------------------
|
||||
|
||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
||||
|
||||
Some additional documentation about raylib design can be found in [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki). Here are the relevant links:
|
||||
|
||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||
- [raylib library design](https://github.com/raysan5/raylib/wiki)
|
||||
- [raylib examples collection](https://github.com/raysan5/raylib/tree/master/examples)
|
||||
- [raylib games collection](https://github.com/raysan5/raylib-games)
|
||||
|
||||
|
||||
contact and networks
|
||||
---------------------
|
||||
|
||||
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
||||
|
||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
||||
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
|
||||
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
||||
|
||||
contributors
|
||||
------------
|
||||
|
||||
<a href="https://github.com/raysan5/raylib/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=raysan5/raylib&max=500&columns=20&anon=1" />
|
||||
</a>
|
||||
|
||||
license
|
||||
-------
|
||||
|
||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
||||
|
||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on [raylib Wiki](https://github.com/raysan5/raylib/wiki) for details.
|
1708
raylib files/raylib-5.5_win64_msvc16/include/raylib.h
Normal file
1708
raylib files/raylib-5.5_win64_msvc16/include/raylib.h
Normal file
File diff suppressed because it is too large
Load Diff
2941
raylib files/raylib-5.5_win64_msvc16/include/raymath.h
Normal file
2941
raylib files/raylib-5.5_win64_msvc16/include/raymath.h
Normal file
File diff suppressed because it is too large
Load Diff
5262
raylib files/raylib-5.5_win64_msvc16/include/rlgl.h
Normal file
5262
raylib files/raylib-5.5_win64_msvc16/include/rlgl.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylib.dll
Normal file
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylib.dll
Normal file
Binary file not shown.
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylib.lib
Normal file
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylib.lib
Normal file
Binary file not shown.
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylibdll.lib
Normal file
BIN
raylib files/raylib-5.5_win64_msvc16/lib/raylibdll.lib
Normal file
Binary file not shown.
95
raylib files/resource_dir.h
Normal file
95
raylib files/resource_dir.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* raylibExtras * Utilities and Shared Components for Raylib
|
||||
*
|
||||
* Resource Dir * function to help find resource dir in common locations
|
||||
*
|
||||
* LICENSE: MIT
|
||||
*
|
||||
* Copyright (c) 2022 Jeffery Myers
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Looks for the specified resource dir in several common locations
|
||||
/// The working dir
|
||||
/// The app dir
|
||||
/// Up to 3 levels above the app dir
|
||||
/// When found the dir will be set as the working dir so that assets can be loaded relative to that.
|
||||
/// </summary>
|
||||
/// <param name="folderName">The name of the resources dir to look for</param>
|
||||
/// <returns>True if a dir with the name was found, false if no change was made to the working dir</returns>
|
||||
inline static bool SearchAndSetResourceDir(const char* folderName)
|
||||
{
|
||||
// check the working dir
|
||||
if (DirectoryExists(folderName))
|
||||
{
|
||||
ChangeDirectory(TextFormat("%s/%s", GetWorkingDirectory(), folderName));
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* appDir = GetApplicationDirectory();
|
||||
|
||||
// check the applicationDir
|
||||
const char* dir = TextFormat("%s%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check one up from the app dir
|
||||
dir = TextFormat("%s../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check two up from the app dir
|
||||
dir = TextFormat("%s../../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check three up from the app dir
|
||||
dir = TextFormat("%s../../../%s", appDir, folderName);
|
||||
if (DirectoryExists(dir))
|
||||
{
|
||||
ChangeDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
BIN
raylib project/raylib project/FirefoxNotoSans-Regular.ttf
Normal file
BIN
raylib project/raylib project/FirefoxNotoSans-Regular.ttf
Normal file
Binary file not shown.
Binary file not shown.
@ -1,58 +1,83 @@
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Tell the window to use vsync and work on high DPI displays
|
||||
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||
|
||||
int windowW = 800;
|
||||
int windowH = 600;
|
||||
|
||||
// Create the window and OpenGL context
|
||||
InitWindow(windowW, windowH, "Hello Raylib");
|
||||
|
||||
Font font = LoadFontEx("arial.ttf", 36, NULL, 0);
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
int posX = 0;
|
||||
int posY = 0;
|
||||
|
||||
Vector2 textPos = { 0.0f, 0.0f };
|
||||
|
||||
// game loop
|
||||
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window
|
||||
{
|
||||
|
||||
if (IsKeyDown(KEY_D)) {
|
||||
textPos.x += 10;
|
||||
}
|
||||
if (IsKeyDown(KEY_A)) {
|
||||
textPos.x -= 10;
|
||||
}
|
||||
if (IsKeyDown(KEY_W)) {
|
||||
textPos.y -= 10;
|
||||
}
|
||||
if (IsKeyDown(KEY_S)) {
|
||||
textPos.y += 10;
|
||||
}
|
||||
|
||||
// drawing
|
||||
BeginDrawing();
|
||||
|
||||
// Setup the back buffer for drawing (clear color and depth buffers)
|
||||
ClearBackground(BLACK);
|
||||
|
||||
// draw some text using the default font
|
||||
//DrawText("Hello Raylib!", posX, posY, 36, WHITE);
|
||||
DrawTextEx(font, "Hello Raylib", textPos, 36, 1, WHITE);
|
||||
DrawText(TextFormat("%2d", GetFPS()), 0, 0, 36, ORANGE);
|
||||
|
||||
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
// destroy the window and cleanup the OpenGL context
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Tell the window to work on high DPI displays
|
||||
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||
|
||||
int CanvasW = 1280;
|
||||
int CanvasH = 800;
|
||||
|
||||
char text[] = "Hello Raylib";
|
||||
|
||||
// Create the window and OpenGL context
|
||||
InitWindow(CanvasW, CanvasH, text);
|
||||
|
||||
Font font = LoadFontEx("NotoSans-Regular.ttf", 90, NULL, 0);
|
||||
SetTextureFilter(font.texture , TEXTURE_FILTER_BILINEAR);
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
int posX = CanvasW / 2;
|
||||
int posY = CanvasH / 2;
|
||||
|
||||
Vector2 textPos = { CanvasW / 2.0f - MeasureTextEx(font, text, (float)font.baseSize, 1).x / 2, CanvasH / 2.0f - (float)font.baseSize };
|
||||
Vector2 textVel = { 0, 0 };
|
||||
|
||||
float dt; // delta time
|
||||
|
||||
float speed = 300.0f;
|
||||
|
||||
// game loop
|
||||
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window
|
||||
{
|
||||
dt = GetFrameTime();
|
||||
|
||||
if (IsKeyDown(KEY_D)) {
|
||||
textVel.x = speed;
|
||||
}
|
||||
else if (IsKeyDown(KEY_A)) {
|
||||
textVel.x = -speed;
|
||||
}
|
||||
else {
|
||||
textVel.x = 0;
|
||||
}
|
||||
|
||||
if (IsKeyDown(KEY_W)) {
|
||||
textVel.y = -speed;
|
||||
}
|
||||
else if (IsKeyDown(KEY_S)) {
|
||||
textVel.y = speed;
|
||||
}
|
||||
else {
|
||||
textVel.y = 0;
|
||||
}
|
||||
|
||||
textPos = Vector2Add(textPos, Vector2Scale(textVel, dt));
|
||||
|
||||
// drawing
|
||||
BeginDrawing();
|
||||
|
||||
// Setup the back buffer for drawing (clear color and depth buffers)
|
||||
ClearBackground(BLACK);
|
||||
|
||||
// draw some text using the default font
|
||||
//DrawText("Hello Raylib!", posX, posY, 36, WHITE);
|
||||
DrawTextEx(font, text, textPos, (float)font.baseSize, 1, WHITE);
|
||||
|
||||
//DrawFPS(0, 0);
|
||||
DrawText(TextFormat("%2d FPS", GetFPS()), 0, 0, 34, ORANGE);
|
||||
DrawText(TextFormat("%4f ms", dt), 0, 34, 34, BEIGE);
|
||||
|
||||
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
UnloadFont(font);
|
||||
|
||||
// destroy the window and cleanup the OpenGL context
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
|
@ -105,11 +105,12 @@
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>include;</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>false</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>winmm.lib;raylib.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>raylib.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>lib</AdditionalLibraryDirectories>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
@ -130,15 +131,17 @@
|
||||
<AdditionalIncludeDirectories>include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>lib</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>winmm.lib;raylib.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>raylib.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "lib\raylib.dll" "$(OutDir)"</Command>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@ -146,6 +149,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\raylib.h" />
|
||||
<ClInclude Include="include\raymath.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -23,5 +23,8 @@
|
||||
<ClInclude Include="include\raylib.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\raymath.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user