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

master
sigonasr2 4 weeks 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. 2
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  5. 62
      Adventures in Lestoria/Arc.cpp
  6. 55
      Adventures in Lestoria/Arc.h
  7. 2
      Adventures in Lestoria/Goblin_Bomb.cpp
  8. 20
      Adventures in Lestoria/OctopusArm.cpp
  9. 2
      Adventures in Lestoria/Oktopus boss.txt
  10. 2
      Adventures in Lestoria/Version.h
  11. 1
      Adventures in Lestoria/assets/config/Monsters.txt
  12. BIN
      Adventures in Lestoria/assets/gamepack.pak
  13. 14
      Adventures in Lestoria/olcUTIL_Geometry2D.h
  14. BIN
      x64/Release/Adventures in Lestoria.exe

@ -282,7 +282,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<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>
</ClCompile>
<Link>
@ -374,6 +374,10 @@
<ClInclude Include="Ability.h" />
<ClInclude Include="AccessoryRowItemDisplay.h" />
<ClInclude Include="Animation.h" />
<ClInclude Include="Arc.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="Attributable.h" />
<ClInclude Include="AttributableStat.h">
<SubType>
@ -764,6 +768,10 @@
<ItemGroup>
<ClCompile Include="Ability.cpp" />
<ClCompile Include="Animation.cpp" />
<ClCompile Include="Arc.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="Arrow.cpp" />
<ClCompile Include="ArtificerDisassembleWindow.cpp">
<SubType>

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

@ -3693,7 +3693,7 @@ void AiL::InitializeGraphics(){
circleCooldownPoints.emplace_back(vf2d{0,0});
squareCircleCooldownPoints.emplace_back(vf2d{0,0});
for(int i=0;i<=360;i+=4){
float angle=util::degToRad(float(i))-PI/2;
float angle=util::degToRad(float(i))-PI/2;
#pragma region Cooldown Circles
if(i==0){circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)});}
circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)});

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

@ -65,7 +65,7 @@ void Monster::STRATEGY::GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string str
m.F(A::SHOOT_TIMER)=m.randomFrameOffset;
SETPHASE(RUN);
}break;
case RUN:{
case RUN:{
m.F(A::SHOOT_TIMER)+=fElapsedTime;
m.F(A::SHOOT_ANIMATION_TIME)-=fElapsedTime;
float distToPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();

@ -48,14 +48,24 @@ INCLUDE_game
void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string strategy){
enum PhaseName{
RUN,
FLY_AWAY,
INIT,
RISE_ANIMATION,
SEARCH,
};
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;
case FLY_AWAY:{
case SEARCH:{
}break;
}

@ -13,7 +13,7 @@ Big bullet: 90
Tentacle: 50
Attack moves
- Boss shots 1 bullet every second
- Boss shots 1 bullet every second
- Every 6. Shot Boss Shots a big bullet that explodes when i gets close to the Player and form a new ring of bullets flying away in a whirl instead of a straight line. (Boss rests for 2 seconds after big bullet)
- Tentacels do a delayed attack
- Every Tentacle and the boss get a 10% Attack buff on each Tentacle death

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

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

@ -1103,7 +1103,21 @@ namespace olc::utils::geom2d
return s >= T2(0) && v >= T2(0) && (s + v) <= T2(2) * A * sign;
}
// 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)
// Check if point overlaps with point (analagous to contains())

Loading…
Cancel
Save