Arc implementation completed. Release Build 11776.

master
sigonasr2 4 weeks ago
parent d85cef1b86
commit 7b165a64d5
  1. 31
      Adventures in Lestoria/Arc.cpp
  2. 8
      Adventures in Lestoria/Arc.h
  3. 2
      Adventures in Lestoria/Oscillator.h
  4. 2
      Adventures in Lestoria/Version.h
  5. BIN
      Adventures in Lestoria/assets/gamepack.pak
  6. 3
      Adventures in Lestoria/olcPixelGameEngine.h
  7. 4
      Adventures in Lestoria/olcUTIL_Geometry2D.h
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -41,22 +41,31 @@ All rights reserved.
INCLUDE_game INCLUDE_game
Arc::Arc(const vf2d pos,const float pointingAngle,const float sweepAngle) Arc::Arc(const vf2d pos,const float radius,const float pointingAngle,const float sweepAngle)
:pos(pos),pointingAngle(pointingAngle),sweepAngle(sweepAngle){ :pos(pos),radius(radius),pointingAngle(pointingAngle),sweepAngle(sweepAngle){
if(sweepAngle<0.f)ERR(std::format("WARNING! Sweep angle must be greater than or equal to 0! Provided Sweep Angle: {}",sweepAngle));
//Use cut-off point between two angles //Use cut-off point between two angles
poly.pos.emplace_back(vf2d{}); //Always add 0,0 poly.pos.emplace_back(pos); //Always add 0,0
int startInd{int(std::fmod(util::radToDeg(pointingAngle-sweepAngle)/4,90))}; float smallestAng{util::radToDeg(pointingAngle-sweepAngle)+90};
int endInd{int(std::fmod(util::radToDeg(pointingAngle+sweepAngle)/4,90))}; float largestAng{util::radToDeg(pointingAngle+sweepAngle)+90};
if(startInd>endInd)std::swap(startInd,endInd); while(smallestAng<0.f)smallestAng+=360;
for(int i=startInd;i<endInd;i++){ while(largestAng<0.f)largestAng+=360;
poly.pos.emplace_back(game->circleCooldownPoints[i]); int startInd{int(std::fmod(smallestAng/4+1,90))};
int endInd{int(std::fmod(largestAng/4+1,90))};
if(startInd>endInd){
startInd=(startInd+3)%90;
}else{
endInd=(endInd+3)%90;
} }
poly.pos.emplace_back(vf2d{}); //Connect back to itself. for(int i=startInd;i!=endInd;i=(i+1)%game->circleCooldownPoints.size()){
poly.pos.emplace_back(pos+game->circleCooldownPoints[i]*radius);
} }
void Arc::Draw(AiL*game,const vf2d pos,const float pointingAngle,const float sweepAngle,const Pixel col){ poly.pos.emplace_back(pos); //Connect back to itself.
}
void Arc::Draw(AiL*game,const Pixel col){
game->SetDecalStructure(DecalStructure::FAN); game->SetDecalStructure(DecalStructure::FAN);
game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col); game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col);
} }
const bool Arc::overlaps(const vf2d checkPos)const{ const bool Arc::overlaps(const vf2d checkPos)const{
return geom2d::overlaps(checkPos,poly);
} }

@ -38,18 +38,20 @@ All rights reserved.
#pragma once #pragma once
#include "olcUTIL_Geometry2D.h" #include "olcUTIL_Geometry2D.h"
#include "Pixel.h"
class AiL; class AiL;
class Arc{ class Arc{
public: 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. //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. MUST BE POSITIVE
Arc(const vf2d pos,const float pointingAngle,const float sweepAngle); Arc(const vf2d pos,const float radius,const float pointingAngle,const float sweepAngle);
void Draw(AiL*game,const vf2d pos,const float pointingAngle,const float sweepAngle,const Pixel col); void Draw(AiL*game,const Pixel col);
const bool overlaps(const vf2d checkPos)const; const bool overlaps(const vf2d checkPos)const;
private: private:
const vf2d pos; const vf2d pos;
const float pointingAngle; const float pointingAngle;
const float sweepAngle; const float sweepAngle;
const float radius;
geom2d::polygon<float>poly; geom2d::polygon<float>poly;
}; };

@ -41,7 +41,7 @@ All rights reserved.
template<class T> template<class T>
class Oscillator{ class Oscillator{
friend class ThrownProjectile; friend struct ThrownProjectile;
public: public:
inline Oscillator() inline Oscillator()
:Oscillator({},{},0.f){} :Oscillator({},{},0.f){}

@ -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 11757 #define VERSION_BUILD 11776
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -383,6 +383,7 @@ return 0;
#define OLC_PGE_DEF #define OLC_PGE_DEF
#pragma region std_includes #pragma region std_includes
#define Arc _OLDARC
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
// | STANDARD INCLUDES | // | STANDARD INCLUDES |
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
@ -573,6 +574,8 @@ namespace X11
#endif #endif
#pragma endregion #pragma endregion
#undef Arc
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
// | olcPixelGameEngine INTERFACE DECLARATION | // | olcPixelGameEngine INTERFACE DECLARATION |
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O

@ -1112,8 +1112,8 @@ namespace olc::utils::geom2d
{ {
int index{1}; int index{1};
std::vector<geom2d::triangle<float>>tris; std::vector<geom2d::triangle<float>>tris;
while(index<polygon.pos.size()-1){ while(index<p2.pos.size()-1){
if(overlaps(p1,geom2d::triangle<float>{polygon.pos[0],polygon.pos[index],polygon.pos[index+1]}))return true; if(overlaps(p1,geom2d::triangle<float>{p2.pos[0],p2.pos[index],p2.pos[index+1]}))return true;
index++; index++;
} }
return false; return false;

Loading…
Cancel
Save