Add project files.

master
sigonasr2 1 year ago
parent c345251fd0
commit bf2ed34855
  1. 31
      ReflectionPrototype.sln
  2. 82
      ReflectionPrototype/ReflectionPrototype.cpp
  3. 143
      ReflectionPrototype/ReflectionPrototype.vcxproj
  4. 30
      ReflectionPrototype/ReflectionPrototype.vcxproj.filters
  5. BIN
      ReflectionPrototype/assets/avatar.png
  6. 6783
      ReflectionPrototype/olcPixelGameEngine.h
  7. 1097
      ReflectionPrototype/olcUTIL_Geometry2D.h

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReflectionPrototype", "ReflectionPrototype\ReflectionPrototype.vcxproj", "{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}"
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
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Debug|x64.ActiveCfg = Debug|x64
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Debug|x64.Build.0 = Debug|x64
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Debug|x86.ActiveCfg = Debug|Win32
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Debug|x86.Build.0 = Debug|Win32
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Release|x64.ActiveCfg = Release|x64
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Release|x64.Build.0 = Release|x64
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Release|x86.ActiveCfg = Release|Win32
{88AD8DB5-1417-429E-ACF4-1D0551E43BDF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2D830A9E-677A-4D1E-B4C3-65E385C4272E}
EndGlobalSection
EndGlobal

@ -0,0 +1,82 @@
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#include "olcUTIL_Geometry2D.h"
#define PI 3.14159
using namespace olc;
// Override base class with your custom functionality
class Example : public olc::PixelGameEngine
{
Decal*image;
vf2d pos;
float time;
float updateTimer;
float rot=0;
public:
Example()
{
// Name your application
sAppName = "Example";
}
public:
bool OnUserCreate() override
{
pos=GetScreenSize()/2;
image=new Decal(new Sprite("assets/avatar.png"));
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
updateTimer-=fElapsedTime;
if(updateTimer<=0){
updateTimer=0.5;
time+=0.6;
}
rot+=fElapsedTime;
pos=GetMousePos();
//DrawRotatedDecal(pos,image,0,image->sprite->Size()/2);
vf2d multiplier={0.5,0.5};
float rotation=rot;
float scaleFactor=0.05; //How much to oscillate between the total scale.
multiplier.x*=(1-abs(sin(time))*scaleFactor);
multiplier.x*=(1-abs(cos(1.5*time))*scaleFactor);
geom2d::rect<float>imgSquare={pos-vf2d(image->sprite->Size()/2)*multiplier.x+vf2d{abs(sin(time))*scaleFactor*image->sprite->width*multiplier.x,0},vf2d(image->sprite->Size())*multiplier};
for(int y=0;y<ScreenHeight();y+=24){
for(int x=0;x<ScreenWidth();x+=24){
geom2d::rect<float>square={{float(x),float(y)},{24,24}};
if(geom2d::overlaps(square,imgSquare)){
vf2d pos=square.pos;
pos.x+=std::max(0.f,imgSquare.pos.x-square.pos.x);
pos.y+=std::max(0.f,imgSquare.pos.y-square.pos.y);
vf2d offset={square.pos.x-imgSquare.pos.x+std::max(0.f,imgSquare.pos.x-square.pos.x),square.pos.y-imgSquare.pos.y+std::max(0.f,imgSquare.pos.y-square.pos.y)};
vf2d size={std::min(24.f,imgSquare.right().start.x-square.pos.x),std::min(24.f,imgSquare.bottom().start.y-square.pos.y)};
vf2d finalOffset=offset/multiplier;
vf2d finalSize=size/multiplier;
finalOffset.y=image->sprite->height-finalOffset.y;
finalSize.y*=-1;
geom2d::line<float>lineTo{imgSquare.middle(),square.middle()};
float angleTo=lineTo.vector().polar().y;
vf2d initialPos=vf2d{cos(rotation)*lineTo.length(),sin(rotation)*lineTo.length()};
vf2d newPos={initialPos.x*cos(angleTo)-initialPos.y*sin(angleTo),initialPos.x*sin(angleTo)+initialPos.y*cos(angleTo)};
DrawPartialRotatedDecal(imgSquare.middle()+newPos,image,rotation,{12,12},finalOffset,finalSize,vf2d{multiplier.x,multiplier.y*-1});
DrawRectDecal(square.pos,square.size,RED);
}else{
DrawRectDecal(square.pos,square.size);
}
}
}
return true;
}
};
int main()
{
Example demo;
if (demo.Construct(1280, 720, 1, 1))
demo.Start();
return 0;
}

@ -0,0 +1,143 @@
<?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>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{88ad8db5-1417-429e-acf4-1d0551e43bdf}</ProjectGuid>
<RootNamespace>ReflectionPrototype</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>
<LanguageStandard>stdcpp17</LanguageStandard>
</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>
<LanguageStandard>stdcpp17</LanguageStandard>
</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>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ReflectionPrototype.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h" />
<ClInclude Include="olcUTIL_Geometry2D.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<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="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<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>
<ClCompile Include="ReflectionPrototype.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="olcUTIL_Geometry2D.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save