Map UVs to original cooldown circle indicator instead. Create a DrawPieArc function to render pies with a UV mapped texture from the center outwards. Remove donut circle indicator generating code. Reduce max vertex count of engine back from 256 -> 128 to maintain low memory footprint. Release Build 10846.
This commit is contained in:
parent
97a9025830
commit
214759c606
@ -3385,6 +3385,18 @@ void AiL::DrawPie(vf2d center,float radius,float degreesCut,Pixel col){
|
|||||||
DrawPolygonDecal(nullptr,circleCooldownPoints,circleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col);
|
DrawPolygonDecal(nullptr,circleCooldownPoints,circleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiL::DrawPieArc(const std::string_view texture,vf2d center,float radius,float degreesCut,Pixel col){
|
||||||
|
std::vector<vf2d>donutUVs{};
|
||||||
|
bool first{true};
|
||||||
|
std::transform(game->circleCooldownPoints.begin(),game->circleCooldownPoints.end(),std::back_inserter(donutUVs),[&first](const vf2d&point){
|
||||||
|
const bool IsFirstPoint{first};
|
||||||
|
first=false;
|
||||||
|
return IsFirstPoint?vf2d{}:vf2d{1,1};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
DrawPolygonDecal(GFX[std::string(texture)].Decal(),circleCooldownPoints,donutUVs,std::max(1,int(degreesCut/4)),center,radius,col);
|
||||||
|
}
|
||||||
|
|
||||||
void AiL::DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col){
|
void AiL::DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col){
|
||||||
DrawPolygonDecal(nullptr,squareCircleCooldownPoints,squareCircleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col);
|
DrawPolygonDecal(nullptr,squareCircleCooldownPoints,squareCircleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col);
|
||||||
}
|
}
|
||||||
@ -3669,26 +3681,20 @@ void AiL::InitializeGraphics(){
|
|||||||
GFX.Reset();
|
GFX.Reset();
|
||||||
Menu::themes.Reset();
|
Menu::themes.Reset();
|
||||||
|
|
||||||
circleCooldownPoints.push_back({0,0});
|
const float innerArcRatio{0.85f};
|
||||||
squareCircleCooldownPoints.push_back({0,0});
|
|
||||||
|
circleCooldownPoints.emplace_back(vf2d{0,0});
|
||||||
|
squareCircleCooldownPoints.emplace_back(vf2d{0,0});
|
||||||
for(int i=0;i<=360;i+=4){
|
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 Donut Circle
|
|
||||||
const float innerArcRatio{0.8f};
|
|
||||||
|
|
||||||
donutCircleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)});
|
|
||||||
donutCircleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)}*innerArcRatio);
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Cooldown Circles
|
#pragma region Cooldown Circles
|
||||||
if(i==0){circleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)});}
|
if(i==0){circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)});}
|
||||||
circleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)});
|
circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)});
|
||||||
vf2d point=vf2d{cos(angle),sin(angle)}*sqrt(2.1f);
|
vf2d point=vf2d{cos(angle),sin(angle)}*sqrt(2.1f);
|
||||||
point.x=std::clamp(point.x,-1.f,1.f);
|
point.x=std::clamp(point.x,-1.f,1.f);
|
||||||
point.y=std::clamp(point.y,-1.f,1.f);
|
point.y=std::clamp(point.y,-1.f,1.f);
|
||||||
if(i==0){squareCircleCooldownPoints.push_back(point);}
|
if(i==0){squareCircleCooldownPoints.emplace_back(point);}
|
||||||
squareCircleCooldownPoints.push_back(point);
|
squareCircleCooldownPoints.emplace_back(point);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,6 @@ private:
|
|||||||
std::vector<int>dropsBeforeLower,dropsAfterLower,dropsBeforeUpper,dropsAfterUpper;
|
std::vector<int>dropsBeforeLower,dropsAfterLower,dropsBeforeUpper,dropsAfterUpper;
|
||||||
std::vector<ZoneData>endZones,upperEndZones;
|
std::vector<ZoneData>endZones,upperEndZones;
|
||||||
std::vector<vf2d>circleCooldownPoints;
|
std::vector<vf2d>circleCooldownPoints;
|
||||||
std::vector<vf2d>donutCircleCooldownPoints;
|
|
||||||
std::vector<vf2d>squareCircleCooldownPoints;
|
std::vector<vf2d>squareCircleCooldownPoints;
|
||||||
std::map<std::string,TilesetData>MAP_TILESETS;
|
std::map<std::string,TilesetData>MAP_TILESETS;
|
||||||
vf2d worldShake={};
|
vf2d worldShake={};
|
||||||
@ -316,6 +315,7 @@ public:
|
|||||||
bool IsReflectiveTile(TilesheetData tileSheet,int tileID);
|
bool IsReflectiveTile(TilesheetData tileSheet,int tileID);
|
||||||
Monster&SpawnMonster(vf2d pos,MonsterData&data,bool upperLevel=false,bool isBossSpawn=false); //Queues a monster for spawning on the next frame.
|
Monster&SpawnMonster(vf2d pos,MonsterData&data,bool upperLevel=false,bool isBossSpawn=false); //Queues a monster for spawning on the next frame.
|
||||||
void DrawPie(vf2d center,float radius,float degreesCut,Pixel col);
|
void DrawPie(vf2d center,float radius,float degreesCut,Pixel col);
|
||||||
|
void DrawPieArc(const std::string_view texture,vf2d center,float radius,float degreesCut,Pixel col); //Draws an arc that has UV coordinates going from (0,0) in the center out to (1,1)
|
||||||
void DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col);
|
void DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col);
|
||||||
void RenderCooldowns();
|
void RenderCooldowns();
|
||||||
void InitializeDefaultKeybinds();
|
void InitializeDefaultKeybinds();
|
||||||
|
@ -90,11 +90,4 @@ void State_GameRun::Draw(AiL*game){
|
|||||||
game->RenderWorld(game->GetElapsedTime());
|
game->RenderWorld(game->GetElapsedTime());
|
||||||
game->RenderHud();
|
game->RenderHud();
|
||||||
Tutorial::Draw();
|
Tutorial::Draw();
|
||||||
|
|
||||||
std::vector<vf2d>largeDonut{};
|
|
||||||
std::transform(game->donutCircleCooldownPoints.begin(),game->donutCircleCooldownPoints.end(),std::back_inserter(largeDonut),[](const vf2d&point){return vf2d{120,120}+point*64.f;});
|
|
||||||
|
|
||||||
game->SetDecalStructure(DecalStructure::STRIP);
|
|
||||||
game->DrawPolygonDecal(nullptr,largeDonut,largeDonut,RED);
|
|
||||||
game->SetDecalStructure(DecalStructure::FAN);
|
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 3
|
#define VERSION_PATCH 3
|
||||||
#define VERSION_BUILD 10836
|
#define VERSION_BUILD 10846
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -586,7 +586,7 @@ namespace olc
|
|||||||
// Pixel Game Engine Advanced Configuration
|
// Pixel Game Engine Advanced Configuration
|
||||||
constexpr inline uint8_t nMouseButtons = 5;
|
constexpr inline uint8_t nMouseButtons = 5;
|
||||||
constexpr inline uint8_t nTabSizeInSpaces = 4;
|
constexpr inline uint8_t nTabSizeInSpaces = 4;
|
||||||
constexpr inline size_t OLC_MAX_VERTS = 256;
|
constexpr inline size_t OLC_MAX_VERTS = 128;
|
||||||
enum rcode { FAIL = 0, OK = 1, NO_FILE = -1 };
|
enum rcode { FAIL = 0, OK = 1, NO_FILE = -1 };
|
||||||
// Thanks to scripticuk and others for updating the key maps
|
// Thanks to scripticuk and others for updating the key maps
|
||||||
// NOTE: The GLUT platform will need updating, open to contributions ;)
|
// NOTE: The GLUT platform will need updating, open to contributions ;)
|
||||||
@ -3056,6 +3056,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
DecalInstance di;
|
DecalInstance di;
|
||||||
di.decal = decal;
|
di.decal = decal;
|
||||||
di.points = uint32_t(pos.size());
|
di.points = uint32_t(pos.size());
|
||||||
@ -3077,6 +3078,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const int startInd, const vf2d&offset, const float scale, const olc::Pixel tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const int startInd, const vf2d&offset, const float scale, const olc::Pixel tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
DecalInstance di;
|
DecalInstance di;
|
||||||
di.decal = decal;
|
di.decal = decal;
|
||||||
di.points = uint32_t(pos.size()-startInd);
|
di.points = uint32_t(pos.size()-startInd);
|
||||||
@ -3104,6 +3106,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel> &tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel> &tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
DecalInstance di;
|
DecalInstance di;
|
||||||
di.decal = decal;
|
di.decal = decal;
|
||||||
di.points = uint32_t(pos.size());
|
di.points = uint32_t(pos.size());
|
||||||
@ -3125,6 +3128,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
std::vector<olc::Pixel> newColours(colours.size(), olc::WHITE);
|
std::vector<olc::Pixel> newColours(colours.size(), olc::WHITE);
|
||||||
std::transform(colours.begin(), colours.end(), newColours.begin(),
|
std::transform(colours.begin(), colours.end(), newColours.begin(),
|
||||||
[&tint](const olc::Pixel pin) { return pin * tint; });
|
[&tint](const olc::Pixel pin) { return pin * tint; });
|
||||||
@ -3134,6 +3138,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<float>& depth, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<float>& depth, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
DecalInstance di;
|
DecalInstance di;
|
||||||
di.decal = decal;
|
di.decal = decal;
|
||||||
di.points = uint32_t(pos.size());
|
di.points = uint32_t(pos.size());
|
||||||
@ -3155,6 +3160,7 @@ namespace olc
|
|||||||
|
|
||||||
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<float>& depth, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint)
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<float>& depth, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint)
|
||||||
{
|
{
|
||||||
|
if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!");
|
||||||
DecalInstance di;
|
DecalInstance di;
|
||||||
di.decal = decal;
|
di.decal = decal;
|
||||||
di.points = uint32_t(pos.size());
|
di.points = uint32_t(pos.size());
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user