Arcs, Cones, Polygon overlap code. Octopus Arm AI initialized.

master
sigonasr2 4 months ago
parent 1bb0ceb096
commit d85cef1b86
  1. 10
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 6
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  4. 62
      Adventures in Lestoria/Arc.cpp
  5. 55
      Adventures in Lestoria/Arc.h
  6. 20
      Adventures in Lestoria/OctopusArm.cpp
  7. 2
      Adventures in Lestoria/Version.h
  8. 1
      Adventures in Lestoria/assets/config/Monsters.txt
  9. BIN
      Adventures in Lestoria/assets/gamepack.pak
  10. 14
      Adventures in Lestoria/olcUTIL_Geometry2D.h
  11. BIN
      x64/Release/Adventures in Lestoria.exe

@ -282,7 +282,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard> <LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\LabUser\Documents\include;C:\Users\niconiconii\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\niconiconii\OneDrive\Documents\include;C:\Users\niconiconii\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;$(ProjectDir)steam;$(ProjectDir)discord-files;C:\Users\LabUser\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\LabUser\Documents\include;C:\Users\niconiconii\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\niconiconii\OneDrive\Documents\include;C:\Users\niconiconii\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\steam;C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
@ -374,6 +374,10 @@
<ClInclude Include="Ability.h" /> <ClInclude Include="Ability.h" />
<ClInclude Include="AccessoryRowItemDisplay.h" /> <ClInclude Include="AccessoryRowItemDisplay.h" />
<ClInclude Include="Animation.h" /> <ClInclude Include="Animation.h" />
<ClInclude Include="Arc.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="Attributable.h" /> <ClInclude Include="Attributable.h" />
<ClInclude Include="AttributableStat.h"> <ClInclude Include="AttributableStat.h">
<SubType> <SubType>
@ -764,6 +768,10 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="Ability.cpp" /> <ClCompile Include="Ability.cpp" />
<ClCompile Include="Animation.cpp" /> <ClCompile Include="Animation.cpp" />
<ClCompile Include="Arc.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="Arrow.cpp" /> <ClCompile Include="Arrow.cpp" />
<ClCompile Include="ArtificerDisassembleWindow.cpp"> <ClCompile Include="ArtificerDisassembleWindow.cpp">
<SubType> <SubType>

@ -708,6 +708,9 @@
<ClInclude Include="DynamicMenuLabel.h"> <ClInclude Include="DynamicMenuLabel.h">
<Filter>Header Files\Interface</Filter> <Filter>Header Files\Interface</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Arc.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">
@ -1265,6 +1268,9 @@
<ClCompile Include="OctopusArm.cpp"> <ClCompile Include="OctopusArm.cpp">
<Filter>Source Files\Monster Strategies</Filter> <Filter>Source Files\Monster Strategies</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Arc.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />

@ -102,6 +102,7 @@ class AiL : public olc::PixelGameEngine
friend class Audio; friend class Audio;
friend class Minimap; friend class Minimap;
friend class MiniAudio; friend class MiniAudio;
friend class Arc;
std::unique_ptr<Player>player; std::unique_ptr<Player>player;
SplashScreen splash; SplashScreen splash;
public: public:

@ -0,0 +1,62 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Arc.h"
#include "AdventuresInLestoria.h"
INCLUDE_game
Arc::Arc(const vf2d pos,const float pointingAngle,const float sweepAngle)
:pos(pos),pointingAngle(pointingAngle),sweepAngle(sweepAngle){
//Use cut-off point between two angles
poly.pos.emplace_back(vf2d{}); //Always add 0,0
int startInd{int(std::fmod(util::radToDeg(pointingAngle-sweepAngle)/4,90))};
int endInd{int(std::fmod(util::radToDeg(pointingAngle+sweepAngle)/4,90))};
if(startInd>endInd)std::swap(startInd,endInd);
for(int i=startInd;i<endInd;i++){
poly.pos.emplace_back(game->circleCooldownPoints[i]);
}
poly.pos.emplace_back(vf2d{}); //Connect back to itself.
}
void Arc::Draw(AiL*game,const vf2d pos,const float pointingAngle,const float sweepAngle,const Pixel col){
game->SetDecalStructure(DecalStructure::FAN);
game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col);
}
const bool Arc::overlaps(const vf2d checkPos)const{
}

@ -0,0 +1,55 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
#include "olcUTIL_Geometry2D.h"
class AiL;
class Arc{
public:
//Define a sweep angle such that each direction will arc that way. Example: PI/2 means a sweep angle from -PI/2 to PI/2.
Arc(const vf2d pos,const float pointingAngle,const float sweepAngle);
void Draw(AiL*game,const vf2d pos,const float pointingAngle,const float sweepAngle,const Pixel col);
const bool overlaps(const vf2d checkPos)const;
private:
const vf2d pos;
const float pointingAngle;
const float sweepAngle;
geom2d::polygon<float>poly;
};

@ -48,14 +48,24 @@ INCLUDE_game
void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy){ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy){
enum PhaseName{ enum PhaseName{
RUN, INIT,
FLY_AWAY, RISE_ANIMATION,
SEARCH,
}; };
switch(PHASE()){ switch(PHASE()){
case RUN:{ case INIT:{
m.PerformAnimation("RISE",game->GetPlayer()->GetPos());
m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
SETPHASE(RISE_ANIMATION);
}break;
case RISE_ANIMATION:{
m.F(A::CASTING_TIMER)-=fElapsedTime;
if(m.F(A::CASTING_TIMER)<=0.f){
m.PerformAnimation("IDLE",game->GetPlayer()->GetPos());
SETPHASE(SEARCH);
}
}break; }break;
case FLY_AWAY:{ case SEARCH:{
}break; }break;
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 11756 #define VERSION_BUILD 11757
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1793,6 +1793,7 @@ Monsters
ATTACKING = 4, 0.15, PingPong ATTACKING = 4, 0.15, PingPong
DEATH = 5, 0.15, OneShot DEATH = 5, 0.15, OneShot
RISE = 5, 0.15, ReverseOneShot RISE = 5, 0.15, ReverseOneShot
ATTACK = 2, 0.3, Repeat
} }
# Drop Item Name, Drop Percentage(0-100%), Drop Min Quantity, Drop Max Quantity # Drop Item Name, Drop Percentage(0-100%), Drop Min Quantity, Drop Max Quantity

@ -1105,6 +1105,20 @@ namespace olc::utils::geom2d
// overlaps(p,p)
// Check if point overlaps with polygon
template<typename T1, typename T2>
inline constexpr bool overlaps(const olc::v_2d<T1>& p1, const polygon<T2>& p2)
{
int index{1};
std::vector<geom2d::triangle<float>>tris;
while(index<polygon.pos.size()-1){
if(overlaps(p1,geom2d::triangle<float>{polygon.pos[0],polygon.pos[index],polygon.pos[index+1]}))return true;
index++;
}
return false;
}
// overlaps(p,p) // overlaps(p,p)
// Check if point overlaps with point (analagous to contains()) // Check if point overlaps with point (analagous to contains())
template<typename T1, typename T2> template<typename T1, typename T2>

Loading…
Cancel
Save