Implement a ViewPort for the minimap as a full circle. Fix a bug with ViewPort PGEX having hardcoded 4 sides for displaying decals. Release Build 8815.
This commit is contained in:
@@ -353,6 +353,8 @@ bool AiL::OnUserCreate(){
|
||||
SetupDiscord();
|
||||
#endif
|
||||
|
||||
minimap.Initialize();
|
||||
|
||||
gameInitialized=true;
|
||||
|
||||
if(!gamepack.Loaded()&&"GENERATE_GAMEPACK"_B){
|
||||
@@ -2228,7 +2230,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
|
||||
|
||||
#pragma region Foreground and Upper Foreground Tile Fade Group Setup (Loading phase 3.5)
|
||||
LoadingScreen::AddPhase([&](){
|
||||
minimap.Initialize();
|
||||
minimap.Reset();
|
||||
return true;
|
||||
});
|
||||
#pragma endregion
|
||||
@@ -2533,7 +2535,7 @@ TilesheetData AiL::GetTileSheet(MapName map,int tileID){
|
||||
size_t slashMarkerSourceDir = tileData[tileData.size()-1].data["source"].find_last_of('/');
|
||||
std::string baseSourceDir=tileData[tileData.size()-1].data["source"].substr(slashMarkerSourceDir+1);
|
||||
int firstgid=stoi(tileData[tileData.size()-1].data["firstgid"]);
|
||||
return {&MAP_TILESETS["assets/maps/"+baseSourceDir],firstgid,MAP_TILESETS["assets/maps/"+baseSourceDir].tilecols[tileID-firstgid]};
|
||||
return {&MAP_TILESETS["assets/maps/"+baseSourceDir],firstgid,MAP_TILESETS["assets/maps/"+baseSourceDir].tilecols[tileID-(firstgid-1)]};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ class AiL : public olc::PixelGameEngine
|
||||
friend class SaveFile;
|
||||
friend class sig::Animation;
|
||||
friend class Audio;
|
||||
friend class Minimap;
|
||||
std::unique_ptr<Player>player;
|
||||
SplashScreen splash;
|
||||
public:
|
||||
|
||||
@@ -44,6 +44,17 @@ All rights reserved.
|
||||
INCLUDE_game
|
||||
|
||||
void Minimap::Initialize(){
|
||||
std::vector<vf2d>enlargedCircle;
|
||||
for(int i=360;i>=0;i-=4){
|
||||
float angle=util::degToRad(float(i))-PI/2;
|
||||
if(i==360){enlargedCircle.push_back(vf2d{cos(angle),sin(angle)}*"Minimap.Minimap HUD Size"_I+"Minimap.Minimap HUD Size"_I);}
|
||||
enlargedCircle.push_back(vf2d{cos(angle),sin(angle)}*"Minimap.Minimap HUD Size"_I+"Minimap.Minimap HUD Size"_I);
|
||||
}
|
||||
mapCircleHud=ViewPort{enlargedCircle};
|
||||
|
||||
}
|
||||
|
||||
void Minimap::Reset(){
|
||||
loadedChunks.clear();
|
||||
|
||||
if(minimap.Sprite()==nullptr)minimap.Create(1,1);
|
||||
@@ -156,11 +167,11 @@ void Minimap::UpdateChunk(const vi2d chunkPos){
|
||||
}
|
||||
|
||||
cover.Decal()->Update();
|
||||
|
||||
LOG(std::format("Chunk {}_{} Revealed",chunkPos.x,chunkPos.y)<<std::endl);
|
||||
}
|
||||
}
|
||||
|
||||
void Minimap::Draw(){
|
||||
game->DrawDecal(vf2d{float(game->ScreenWidth()-cover.Sprite()->width),0},cover.Decal());
|
||||
mapCircleHud.DrawRotatedDecal(vf2d{"Minimap.Minimap HUD Size"_I/2.f,"Minimap.Minimap HUD Size"_I/2.f},cover.Decal(),0.f,game->GetPlayer()->GetPos()/24);
|
||||
mapCircleHud.DrawStringDecal({0,0},"Hello World! Hello World! Hello World! Hello World! \nHello World! Hello World! Hello World! Hello World! \nHello World! Hello World! Hello World! ");
|
||||
mapCircleHud.drawEdges();
|
||||
}
|
||||
@@ -37,14 +37,18 @@ All rights reserved.
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
#include "olcPGEX_ViewPort.h"
|
||||
|
||||
class Minimap{
|
||||
public:
|
||||
void Initialize();
|
||||
void Reset();
|
||||
void Update();
|
||||
void Draw();
|
||||
|
||||
void UpdateChunk(const vi2d chunkPos);
|
||||
private:
|
||||
ViewPort mapCircleHud;
|
||||
Renderable minimap;
|
||||
Renderable cover;
|
||||
std::unordered_set<std::string>loadedChunks;
|
||||
|
||||
@@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 1
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 8781
|
||||
#define VERSION_BUILD 8815
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
Minimap
|
||||
{
|
||||
# Minimap Hud Size
|
||||
Minimap HUD Size = 48
|
||||
|
||||
# Chunk size in tiles
|
||||
Chunk Size = 16
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="40" height="40" tilewidth="24" tileheight="24" infinite="0" nextlayerid="8" nextobjectid="1">
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="40" height="40" tilewidth="24" tileheight="24" infinite="0" nextlayerid="8" nextobjectid="1">
|
||||
<tileset firstgid="1" source="Tilesheet_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="2913" source="Decorations_c1_No_Shadow24x24.tsx"/>
|
||||
<layer id="2" name="Layer 1" width="40" height="40">
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace olc {
|
||||
public:
|
||||
ViewPort();
|
||||
ViewPort(std::vector<vf2d> vertices, vf2d offset = {0, 0});
|
||||
geom2d::rect<float>rect;
|
||||
geom2d::rect<float>rect{};
|
||||
virtual ~ViewPort();
|
||||
void addPoint(vf2d point);
|
||||
void clear();
|
||||
@@ -533,16 +533,18 @@ void olc::ViewPort::drawClippedDecal(Decal *decal,
|
||||
|
||||
vf2d min={std::numeric_limits<float>::max(),std::numeric_limits<float>::max()},max;
|
||||
bool pointsOutside=false;
|
||||
for(vf2d&points:outputList){
|
||||
if(!geom2d::contains(rect,points)){
|
||||
pointsOutside=true;
|
||||
break;
|
||||
if(rect!=geom2d::rect<float>{}){
|
||||
for(vf2d&points:outputList){
|
||||
if(!geom2d::contains(rect,points)){
|
||||
pointsOutside=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{pointsOutside=true;}
|
||||
if(!pointsOutside)goto render;
|
||||
for (auto i = 0u; i < clipVertices.size(); i++) {
|
||||
auto clipA = clipVertices[i];
|
||||
auto clipB = clipVertices[(i + 1) % 4];
|
||||
auto clipB = clipVertices[(i + 1) % clipVertices.size()];
|
||||
|
||||
auto inputList{outputList};
|
||||
auto inputUvs{outputUvs};
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user