Merge pull request 'AreaHighlightTest' (#57) from AreaHighlightTest into master

Reviewed-on: #57
mac-build
sigonasr2 6 months ago
commit e4fddc0c6d
  1. 5
      Adventures in Lestoria/Adventures in Lestoria.tiled-project
  2. 13
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  3. 18
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  4. 24
      Adventures in Lestoria/AdventuresInLestoria.cpp
  5. 171
      Adventures in Lestoria/Pixel.cpp
  6. 109
      Adventures in Lestoria/Pixel.h
  7. 103
      Adventures in Lestoria/StageMaskPolygon.cpp
  8. 67
      Adventures in Lestoria/StageMaskPolygon.h
  9. 8
      Adventures in Lestoria/TMXParser.h
  10. 2
      Adventures in Lestoria/Version.h
  11. 1177
      Adventures in Lestoria/assets/Campaigns/Boss_2.tmx
  12. 1
      Adventures in Lestoria/assets/config/gfx/gfx.txt
  13. 2
      Adventures in Lestoria/assets/config/levels.txt
  14. BIN
      Adventures in Lestoria/assets/gamepack.pak
  15. BIN
      Adventures in Lestoria/assets/safeIndicatorGradient.png
  16. 170
      Adventures in Lestoria/olcPixelGameEngine.h
  17. 6
      Adventures in Lestoria/olcUTIL_Geometry2D.h
  18. BIN
      x64/Release/Adventures in Lestoria.exe

@ -330,6 +330,11 @@
"type": "string",
"value": "None"
},
{
"name": "Create Optimization Map (Override)",
"type": "bool",
"value": false
},
{
"name": "Dev Completion Time - Ranger (s)",
"type": "float",

@ -429,6 +429,10 @@
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="Pixel.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="PlayerMoneyLabel.h">
<SubType>
</SubType>
@ -511,6 +515,10 @@
<ClInclude Include="Slider.h" />
<ClInclude Include="SoundEffect.h" />
<ClInclude Include="SpawnEncounterLabel.h" />
<ClInclude Include="StageMaskPolygon.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="State.h" />
<ClInclude Include="State_Death.h">
<SubType>
@ -849,6 +857,7 @@
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="Pixel.cpp" />
<ClCompile Include="RunAway.cpp" />
<ClCompile Include="RunTowards.cpp" />
<ClCompile Include="Pathfinding.cpp" />
@ -886,6 +895,10 @@
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="StageMaskPolygon.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="State_Death.cpp">
<SubType>
</SubType>

@ -91,6 +91,12 @@
<Filter Include="Header Files\steam">
<UniqueIdentifier>{ac44510a-638e-4ae5-8529-2c68dddad459}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine">
<UniqueIdentifier>{1b310925-7ec7-4584-8c9c-2154a6e0df80}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine">
<UniqueIdentifier>{aaa148fb-5e34-4c35-a5bf-65ee8f2c0fb1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h">
@ -645,6 +651,12 @@
<ClInclude Include="Overlay.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StageMaskPolygon.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Pixel.h">
<Filter>Header Files\Engine</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">
@ -1085,6 +1097,12 @@
<ClCompile Include="BreakingPillar.cpp">
<Filter>Source Files\Monster Strategies</Filter>
</ClCompile>
<ClCompile Include="StageMaskPolygon.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Pixel.cpp">
<Filter>Source Files\Engine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -81,6 +81,7 @@ All rights reserved.
#include "Tutorial.h"
#include "SteamKeyboardCallbackHandler.h"
#include "SteamStatsReceivedHandler.h"
#include "StageMaskPolygon.h"
INCLUDE_EMITTER_LIST
INCLUDE_ITEM_CATEGORIES
@ -970,6 +971,19 @@ void AiL::RenderWorld(float fElapsedTime){
PopulateRenderLists();
auto RenderPlayer=[&](vf2d pos,vf2d scale){
SetWorldColor(PixelLerp(DARK_BLUE,BLACK,sin(geom2d::pi*GetRunTime()*2)));
if(GetCurrentMapData().provideOptimization&&!LoadingScreen::loading){
StageMaskPolygon poly{
{
view.ScreenToWorld(GetMousePos()-vf2d{50,50}),
view.ScreenToWorld(GetMousePos()+vf2d{100,-20}),
view.ScreenToWorld(GetMousePos()+vf2d{200,200}),
view.ScreenToWorld(GetMousePos()+vf2d{-50,150}),
view.ScreenToWorld(GetMousePos()+vf2d{-120,90}),
},"safeIndicatorGradient.png",PixelLerp(VERY_DARK_BLUE,BLACK,sin(geom2d::pi*GetRunTime()*2))
};
poly.Draw();
}
if(player->IsInvisible())return;
vf2d playerScale=vf2d(player->GetSizeMult(),player->GetSizeMult());
int count=0;
@ -2217,7 +2231,7 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
}
}
if(MAP_DATA[map].MapData.optimized){
if(MAP_DATA[map].MapData.optimized||MAP_DATA[map].MapData.provideOptimization){
LOG("Generating optimized map for Map "<<map);
MAP_DATA[map].optimizedTile=NEW Renderable();
MAP_DATA[map].optimizedTile->Create(MAP_DATA[map].MapData.width*MAP_DATA[map].MapData.tilewidth,MAP_DATA[map].MapData.height*MAP_DATA[map].MapData.tileheight);
@ -2245,8 +2259,10 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
SetPixelMode(prevMode);
MAP_DATA[map].optimizedTile->Decal()->Update();
SetDrawTarget(nullptr);
LOG(" Clearing Layer Data...");
MAP_DATA[map].LayerData.clear();
if(!MAP_DATA[map].MapData.provideOptimization){
MAP_DATA[map].LayerData.clear();
LOG(" Clearing Layer Data...");
}
}
}
@ -2732,7 +2748,7 @@ bool AiL::IsOverlayLayer(LayerTag&layer){
const geom2d::rect<float>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel)const{
const MapTag&mapData=MAP_DATA.at(map).MapData;
if(pos.x<0||pos.y<0||pos.x>=mapData.width*mapData.tilewidth||pos.y>=mapData.height*mapData.tilewidth)return NO_COLLISION;
if(MAP_DATA.at(map).optimizedTile)return NO_COLLISION; //Overworld map has no collision.
if(GetCurrentMapData().optimized)return NO_COLLISION; //Overworld map has no collision.
bool hasTerrain=false;
for(const LayerTag&layer:MAP_DATA.at(map).LayerData){ //Figure out if any tile at this position is terrain. If so, we have a collision box to check.

@ -0,0 +1,171 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2018 - 2024 OneLoneCoder.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.
Links
~~~~~
YouTube: https://www.youtube.com/javidx9
https://www.youtube.com/javidx9extra
Discord: https://discord.gg/WhwHUMV
Twitter: https://www.twitter.com/javidx9
Twitch: https://www.twitch.tv/javidx9
GitHub: https://www.github.com/onelonecoder
Homepage: https://www.onelonecoder.com
Patreon: https://www.patreon.com/javidx9
Community: https://community.onelonecoder.com
*/
#pragma endregion
#include "Pixel.h"
#include <utility>
namespace olc{
// O------------------------------------------------------------------------------O
// | olc::Pixel IMPLEMENTATION |
// O------------------------------------------------------------------------------O
#if !defined(OLC_IGNORE_PIXEL)
Pixel::Pixel()
{ r = 0; g = 0; b = 0; a = nDefaultAlpha; }
Pixel::Pixel(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
{ n = red | (green << 8) | (blue << 16) | (alpha << 24); } // Thanks jarekpelczar
Pixel::Pixel(uint32_t p)
{ n = p; }
bool Pixel::operator==(const Pixel& p) const
{ return n == p.n; }
bool Pixel::operator!=(const Pixel& p) const
{ return n != p.n; }
Pixel Pixel::operator * (const float i) const
{
float fR = std::min(255.0f, std::max(0.0f, float(r) * i));
float fG = std::min(255.0f, std::max(0.0f, float(g) * i));
float fB = std::min(255.0f, std::max(0.0f, float(b) * i));
return Pixel(uint8_t(fR), uint8_t(fG), uint8_t(fB), a);
}
Pixel Pixel::operator / (const float i) const
{
float fR = std::min(255.0f, std::max(0.0f, float(r) / i));
float fG = std::min(255.0f, std::max(0.0f, float(g) / i));
float fB = std::min(255.0f, std::max(0.0f, float(b) / i));
return Pixel(uint8_t(fR), uint8_t(fG), uint8_t(fB), a);
}
Pixel& Pixel::operator *=(const float i)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * i)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * i)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * i)));
return *this;
}
Pixel& Pixel::operator /=(const float i)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) / i)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) / i)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) / i)));
return *this;
}
Pixel Pixel::operator + (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, int(r) + int(p.r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, int(g) + int(p.g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, int(b) + int(p.b))));
return Pixel(nR, nG, nB, a);
}
Pixel Pixel::operator - (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, int(r) - int(p.r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, int(g) - int(p.g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, int(b) - int(p.b))));
return Pixel(nR, nG, nB, a);
}
Pixel& Pixel::operator += (const Pixel& p)
{
this->r = uint8_t(std::min(255, std::max(0, int(r) + int(p.r))));
this->g = uint8_t(std::min(255, std::max(0, int(g) + int(p.g))));
this->b = uint8_t(std::min(255, std::max(0, int(b) + int(p.b))));
return *this;
}
Pixel& Pixel::operator -= (const Pixel& p) // Thanks Au Lit
{
this->r = uint8_t(std::min(255, std::max(0, int(r) - int(p.r))));
this->g = uint8_t(std::min(255, std::max(0, int(g) - int(p.g))));
this->b = uint8_t(std::min(255, std::max(0, int(b) - int(p.b))));
return *this;
}
Pixel Pixel::operator * (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * float(p.r) / 255.0f)));
uint8_t nG = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * float(p.g) / 255.0f)));
uint8_t nB = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * float(p.b) / 255.0f)));
uint8_t nA = uint8_t(std::min(255.0f, std::max(0.0f, float(a) * float(p.a) / 255.0f)));
return Pixel(nR, nG, nB, nA);
}
Pixel& Pixel::operator *=(const Pixel& p)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * float(p.r) / 255.0f)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * float(p.g) / 255.0f)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * float(p.b) / 255.0f)));
this->a = uint8_t(std::min(255.0f, std::max(0.0f, float(a) * float(p.a) / 255.0f)));
return *this;
}
Pixel Pixel::inv() const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, 255 - int(r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, 255 - int(g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, 255 - int(b))));
return Pixel(nR, nG, nB, a);
}
Pixel PixelF(float red, float green, float blue, float alpha)
{ return Pixel(uint8_t(red * 255.0f), uint8_t(green * 255.0f), uint8_t(blue * 255.0f), uint8_t(alpha * 255.0f)); }
Pixel PixelLerp(const olc::Pixel& p1, const olc::Pixel& p2, float t)
{ return (p2 * t) + p1 * (1.0f - t); }
#endif
}

@ -0,0 +1,109 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2018 - 2024 OneLoneCoder.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.
Links
~~~~~
YouTube: https://www.youtube.com/javidx9
https://www.youtube.com/javidx9extra
Discord: https://discord.gg/WhwHUMV
Twitter: https://www.twitter.com/javidx9
Twitch: https://www.twitch.tv/javidx9
GitHub: https://www.github.com/onelonecoder
Homepage: https://www.onelonecoder.com
Patreon: https://www.patreon.com/javidx9
Community: https://community.onelonecoder.com
*/
#pragma endregion
#pragma once
#include <cstdint>
// O------------------------------------------------------------------------------O
// | olc::Pixel IMPLEMENTATION |
// O------------------------------------------------------------------------------O
// O------------------------------------------------------------------------------O
// | olc::Pixel - Represents a 32-Bit RGBA colour |
// O------------------------------------------------------------------------------O
namespace olc{
constexpr inline uint8_t nDefaultAlpha = 0xFF;
constexpr inline uint32_t nDefaultPixel = (nDefaultAlpha << 24);
#if !defined(OLC_IGNORE_PIXEL)
struct Pixel
{
union
{
uint32_t n = nDefaultPixel;
struct { uint8_t r; uint8_t g; uint8_t b; uint8_t a; };
};
enum Mode { NORMAL, MASK, ALPHA, CUSTOM };
Pixel();
Pixel(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = nDefaultAlpha);
Pixel(uint32_t p);
Pixel& operator = (const Pixel& v) = default;
bool operator ==(const Pixel& p) const;
bool operator !=(const Pixel& p) const;
Pixel operator * (const float i) const;
Pixel operator / (const float i) const;
Pixel& operator *=(const float i);
Pixel& operator /=(const float i);
Pixel operator + (const Pixel& p) const;
Pixel operator - (const Pixel& p) const;
Pixel& operator +=(const Pixel& p);
Pixel& operator -=(const Pixel& p);
Pixel operator * (const Pixel& p) const;
Pixel& operator *=(const Pixel& p);
Pixel inv() const;
};
Pixel PixelF(float red, float green, float blue, float alpha = 1.0f);
Pixel PixelLerp(const olc::Pixel& p1, const olc::Pixel& p2, float t);
// O------------------------------------------------------------------------------O
// | USEFUL CONSTANTS |
// O------------------------------------------------------------------------------O
static const Pixel
GREY(192, 192, 192), DARK_GREY(128, 128, 128), VERY_DARK_GREY(64, 64, 64),
RED(255, 0, 0), DARK_RED(128, 0, 0), VERY_DARK_RED(64, 0, 0),
YELLOW(255, 255, 0), DARK_YELLOW(128, 128, 0), VERY_DARK_YELLOW(64, 64, 0),
GREEN(0, 255, 0), DARK_GREEN(0, 128, 0), VERY_DARK_GREEN(0, 64, 0),
CYAN(0, 255, 255), DARK_CYAN(0, 128, 128), VERY_DARK_CYAN(0, 64, 64),
BLUE(0, 0, 255), DARK_BLUE(0, 0, 128), VERY_DARK_BLUE(0, 0, 64),
MAGENTA(255, 0, 255), DARK_MAGENTA(128, 0, 128), VERY_DARK_MAGENTA(64, 0, 64),
WHITE(255, 255, 255), BLACK(0, 0, 0), BLANK(0, 0, 0, 0);
#endif
}

@ -0,0 +1,103 @@
#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 "StageMaskPolygon.h"
#include "AdventuresInLestoria.h"
#include "DEFINES.h"
#include "LoadingScreen.h"
#include "util.h"
INCLUDE_game
INCLUDE_GFX
StageMaskPolygon::StageMaskPolygon(const std::vector<vf2d>&points,const std::string&texture,const Pixel overlayCol)
:polygon(geom2d::polygon<float>{points}){
if(LoadingScreen::loading)ERR("WARNING! A stage mask overlay attempted to initialize itself before the stage finished! THIS IS NOT ALLOWED!");
if(!game->MAP_DATA.at(game->GetCurrentMapName()).GetOptimizedMap())ERR(std::format("WARNING! No optimized map found for stage {} while trying to create a Stage Polygon! THIS IS NOT ALLOWED!",game->GetCurrentMapName()));
if(texture.length()>0)overlay=StageMaskPolygon::StageMaskOverlay{points,texture,overlayCol};
std::transform(points.begin(),points.end(),std::back_inserter(uvs.pos),[&](const vf2d&point){return point/game->GetCurrentMap().GetOptimizedMap()->Sprite()->Size();});
}
StageMaskPolygon::StageMaskOverlay::StageMaskOverlay(const std::vector<vf2d>&points,const std::string&texture,const Pixel overlayCol)
:overlayPolygon(geom2d::polygon<float>{points}),texture(texture),overlayCol(overlayCol){
if(!GFX.count(texture))ERR(std::format("WARNING! Texture {} does not exist while trying to initialize Stage Mask Overlay!",texture));
overlayPolygon.pos.insert(overlayPolygon.pos.begin(),overlayPolygon.middle()); //Insert the middle point to the front of the overlay polygon's point list.
//Copy the first point provided from the original polygon to the end of the new overlay polygon since we have to fully connect the polygon for the texture to show up correctly.
overlayPolygon.pos.push_back(points[0]);
bool first=false;
std::transform(overlayPolygon.pos.begin(),overlayPolygon.pos.end(),std::back_inserter(overlayUVs.pos),[&](const vf2d&point){
if(!first){
first=true;
return vf2d{0.f,0.f};
}else{
return vf2d{1.f,1.f};
}
});
}
const Pixel StageMaskPolygon::StageMaskOverlay::GetColor()const{
return overlayCol;
}
const geom2d::polygon<float>&StageMaskPolygon::StageMaskOverlay::GetPolygon()const{
return overlayPolygon;
}
void StageMaskPolygon::StageMaskOverlay::Draw()const{
game->view.DrawPolygonDecal(GFX.at(texture).Decal(),overlayPolygon.pos,overlayUVs.pos,GetColor());
}
const bool StageMaskPolygon::HasOverlay()const{
return overlay.has_value();
}
void StageMaskPolygon::SetBlendColor(const Pixel overlayCol){
if(!HasOverlay())ERR("WARNING! Trying to set the blend color when there is no overlay on this stage mask polygon! THIS IS NOT ALLOWED!");
overlay.value().overlayCol=overlayCol;
}
const StageMaskPolygon::StageMaskOverlay&StageMaskPolygon::GetOverlay()const{
return overlay.value();
}
void StageMaskPolygon::Draw()const{
game->view.DrawPolygonDecal(game->GetCurrentMap().GetOptimizedMap()->Decal(),polygon.pos,uvs.pos);
if(HasOverlay())GetOverlay().Draw();
}

@ -0,0 +1,67 @@
#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 "Pixel.h"
#include "olcUTIL_Geometry2D.h"
class StageMaskPolygon{
class StageMaskOverlay{
friend class StageMaskPolygon;
private:
//The stage mask overlay auto-forms a UV mapping where the center is {0,0} and the edges are {1,1}. Use this to shape a texture with the desired outline you want.
StageMaskOverlay(const std::vector<vf2d>&points,const std::string&texture,const Pixel overlayCol=BLANK);
const Pixel GetColor()const;
const geom2d::polygon<float>&GetPolygon()const;
void Draw()const;
std::string texture;
geom2d::polygon<float>overlayPolygon; //The overlay polygon uses a middle point so that a texture can fade in towards the center.
geom2d::polygon<float>overlayUVs;
Pixel overlayCol;
};
public:
StageMaskPolygon(const std::vector<vf2d>&points,const std::string&texture="",const Pixel overlayCol=BLANK);
void SetBlendColor(const Pixel overlayCol);
const bool HasOverlay()const;
const StageMaskOverlay&GetOverlay()const;
void Draw()const;
private:
geom2d::polygon<float>polygon;
geom2d::polygon<float>uvs;
std::optional<StageMaskOverlay>overlay;
};

@ -76,6 +76,7 @@ struct MapTag{
int width=0,height=0;
int tilewidth=0,tileheight=0;
bool optimized=false; //An optimized map will require us to flatten it out and use it as a single tile.
bool provideOptimization=false; //An optimized map will require us to flatten it out and use it as a single tile.
vi2d playerSpawnLocation;
vi2d MapSize; //The number of tiles in width and height of this map.
vi2d TileSize; //How large in pixels the map's tiles are.
@ -150,6 +151,7 @@ public:
const std::string_view GetMapDisplayName()const;
const bool HasMoreSpawns()const; //Returns whether or not there are more spawns for the spawn controller.
const int Spawn_pop(); //Grabs the next spawn controller ID and removes it from the stack.
const Renderable const*GetOptimizedMap()const;
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
std::string FormatSpawnerData(std::ostream& os, std::map<int,SpawnerTag>tiles);
friend std::ostream& operator << (std::ostream& os, Map& rhs);
@ -326,6 +328,9 @@ class TMXParser{
spawnControllerIDs.value().pop();
return nextSpawnId;
}
const Renderable const*Map::GetOptimizedMap()const{
return optimizedTile;
}
NPCData::NPCData(){}
NPCData::NPCData(XMLTag npcTag){
const std::array<std::string,7>tags={"Function","NPC Name","Roaming Range","Unlock Condition","Spritesheet","x","y"};
@ -487,6 +492,9 @@ class TMXParser{
if (newTag.tag=="property"&&newTag.data["name"]=="Optimize"&&newTag.data["value"]=="true") {
parsedMapInfo.MapData.optimized=true;
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Create Optimization Map (Override)"&&newTag.data["value"]=="true") {
parsedMapInfo.MapData.provideOptimization=true;
}else
if (newTag.tag=="property"&&newTag.data["name"]=="Boss Title Display") {
parsedMapInfo.SpawnerData[prevSpawner].bossNameDisplay=newTag.data["value"];
}else

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 9554
#define VERSION_BUILD 9572
#define stringify(a) stringify_(a)
#define stringify_(a) #a

File diff suppressed because it is too large Load Diff

@ -104,6 +104,7 @@ Images
GFX_Wind2 = wind2.png
GFX_WindObjects = commercial_assets/wind_solid_objects.png
GFX_LargeTornado = large_tornado.png
GFX_SafeAreaIndicator = safeIndicatorGradient.png
# Ability Icons
GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png

@ -148,7 +148,7 @@ Levels
}
BOSS_2_B
{
Map File = Boss_2_B.tmx
Map File = Boss_2.tmx
# Specify item, min quantity, and max quantity of items. Optionally specify a % drop chance per item.
# Loot[0] = Berries, 1, 5, 100%
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

@ -406,6 +406,7 @@ return 0;
#include <cstring>
#include "Error.h"
#include "olcUTIL_Geometry2D.h"
#include "Pixel.h"
#pragma endregion
#define PGE_VER 225
@ -583,62 +584,9 @@ namespace olc
// Pixel Game Engine Advanced Configuration
constexpr inline uint8_t nMouseButtons = 5;
constexpr inline uint8_t nDefaultAlpha = 0xFF;
constexpr inline uint32_t nDefaultPixel = (nDefaultAlpha << 24);
constexpr inline uint8_t nTabSizeInSpaces = 4;
constexpr inline size_t OLC_MAX_VERTS = 128;
enum rcode { FAIL = 0, OK = 1, NO_FILE = -1 };
// O------------------------------------------------------------------------------O
// | olc::Pixel - Represents a 32-Bit RGBA colour |
// O------------------------------------------------------------------------------O
#if !defined(OLC_IGNORE_PIXEL)
struct Pixel
{
union
{
uint32_t n = nDefaultPixel;
struct { uint8_t r; uint8_t g; uint8_t b; uint8_t a; };
};
enum Mode { NORMAL, MASK, ALPHA, CUSTOM };
Pixel();
Pixel(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = nDefaultAlpha);
Pixel(uint32_t p);
Pixel& operator = (const Pixel& v) = default;
bool operator ==(const Pixel& p) const;
bool operator !=(const Pixel& p) const;
Pixel operator * (const float i) const;
Pixel operator / (const float i) const;
Pixel& operator *=(const float i);
Pixel& operator /=(const float i);
Pixel operator + (const Pixel& p) const;
Pixel operator - (const Pixel& p) const;
Pixel& operator +=(const Pixel& p);
Pixel& operator -=(const Pixel& p);
Pixel operator * (const Pixel& p) const;
Pixel& operator *=(const Pixel& p);
Pixel inv() const;
};
Pixel PixelF(float red, float green, float blue, float alpha = 1.0f);
Pixel PixelLerp(const olc::Pixel& p1, const olc::Pixel& p2, float t);
// O------------------------------------------------------------------------------O
// | USEFUL CONSTANTS |
// O------------------------------------------------------------------------------O
static const Pixel
GREY(192, 192, 192), DARK_GREY(128, 128, 128), VERY_DARK_GREY(64, 64, 64),
RED(255, 0, 0), DARK_RED(128, 0, 0), VERY_DARK_RED(64, 0, 0),
YELLOW(255, 255, 0), DARK_YELLOW(128, 128, 0), VERY_DARK_YELLOW(64, 64, 0),
GREEN(0, 255, 0), DARK_GREEN(0, 128, 0), VERY_DARK_GREEN(0, 64, 0),
CYAN(0, 255, 255), DARK_CYAN(0, 128, 128), VERY_DARK_CYAN(0, 64, 64),
BLUE(0, 0, 255), DARK_BLUE(0, 0, 128), VERY_DARK_BLUE(0, 0, 64),
MAGENTA(255, 0, 255), DARK_MAGENTA(128, 0, 128), VERY_DARK_MAGENTA(64, 0, 64),
WHITE(255, 255, 255), BLACK(0, 0, 0), BLANK(0, 0, 0, 0);
#endif
// Thanks to scripticuk and others for updating the key maps
// NOTE: The GLUT platform will need updating, open to contributions ;)
enum Key
@ -1609,122 +1557,6 @@ namespace olc
std::string PixelGameEngine::White;
std::string PixelGameEngine::Black;
std::string PixelGameEngine::Reset; //Will render the original color provided when used.
// O------------------------------------------------------------------------------O
// | olc::Pixel IMPLEMENTATION |
// O------------------------------------------------------------------------------O
#if !defined(OLC_IGNORE_PIXEL)
Pixel::Pixel()
{ r = 0; g = 0; b = 0; a = nDefaultAlpha; }
Pixel::Pixel(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
{ n = red | (green << 8) | (blue << 16) | (alpha << 24); } // Thanks jarekpelczar
Pixel::Pixel(uint32_t p)
{ n = p; }
bool Pixel::operator==(const Pixel& p) const
{ return n == p.n; }
bool Pixel::operator!=(const Pixel& p) const
{ return n != p.n; }
Pixel Pixel::operator * (const float i) const
{
float fR = std::min(255.0f, std::max(0.0f, float(r) * i));
float fG = std::min(255.0f, std::max(0.0f, float(g) * i));
float fB = std::min(255.0f, std::max(0.0f, float(b) * i));
return Pixel(uint8_t(fR), uint8_t(fG), uint8_t(fB), a);
}
Pixel Pixel::operator / (const float i) const
{
float fR = std::min(255.0f, std::max(0.0f, float(r) / i));
float fG = std::min(255.0f, std::max(0.0f, float(g) / i));
float fB = std::min(255.0f, std::max(0.0f, float(b) / i));
return Pixel(uint8_t(fR), uint8_t(fG), uint8_t(fB), a);
}
Pixel& Pixel::operator *=(const float i)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * i)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * i)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * i)));
return *this;
}
Pixel& Pixel::operator /=(const float i)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) / i)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) / i)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) / i)));
return *this;
}
Pixel Pixel::operator + (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, int(r) + int(p.r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, int(g) + int(p.g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, int(b) + int(p.b))));
return Pixel(nR, nG, nB, a);
}
Pixel Pixel::operator - (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, int(r) - int(p.r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, int(g) - int(p.g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, int(b) - int(p.b))));
return Pixel(nR, nG, nB, a);
}
Pixel& Pixel::operator += (const Pixel& p)
{
this->r = uint8_t(std::min(255, std::max(0, int(r) + int(p.r))));
this->g = uint8_t(std::min(255, std::max(0, int(g) + int(p.g))));
this->b = uint8_t(std::min(255, std::max(0, int(b) + int(p.b))));
return *this;
}
Pixel& Pixel::operator -= (const Pixel& p) // Thanks Au Lit
{
this->r = uint8_t(std::min(255, std::max(0, int(r) - int(p.r))));
this->g = uint8_t(std::min(255, std::max(0, int(g) - int(p.g))));
this->b = uint8_t(std::min(255, std::max(0, int(b) - int(p.b))));
return *this;
}
Pixel Pixel::operator * (const Pixel& p) const
{
uint8_t nR = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * float(p.r) / 255.0f)));
uint8_t nG = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * float(p.g) / 255.0f)));
uint8_t nB = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * float(p.b) / 255.0f)));
uint8_t nA = uint8_t(std::min(255.0f, std::max(0.0f, float(a) * float(p.a) / 255.0f)));
return Pixel(nR, nG, nB, nA);
}
Pixel& Pixel::operator *=(const Pixel& p)
{
this->r = uint8_t(std::min(255.0f, std::max(0.0f, float(r) * float(p.r) / 255.0f)));
this->g = uint8_t(std::min(255.0f, std::max(0.0f, float(g) * float(p.g) / 255.0f)));
this->b = uint8_t(std::min(255.0f, std::max(0.0f, float(b) * float(p.b) / 255.0f)));
this->a = uint8_t(std::min(255.0f, std::max(0.0f, float(a) * float(p.a) / 255.0f)));
return *this;
}
Pixel Pixel::inv() const
{
uint8_t nR = uint8_t(std::min(255, std::max(0, 255 - int(r))));
uint8_t nG = uint8_t(std::min(255, std::max(0, 255 - int(g))));
uint8_t nB = uint8_t(std::min(255, std::max(0, 255 - int(b))));
return Pixel(nR, nG, nB, a);
}
Pixel PixelF(float red, float green, float blue, float alpha)
{ return Pixel(uint8_t(red * 255.0f), uint8_t(green * 255.0f), uint8_t(blue * 255.0f), uint8_t(alpha * 255.0f)); }
Pixel PixelLerp(const olc::Pixel& p1, const olc::Pixel& p2, float t)
{ return (p2 * t) + p1 * (1.0f - t); }
#endif
// O------------------------------------------------------------------------------O
// | olc::Sprite IMPLEMENTATION |
// O------------------------------------------------------------------------------O

@ -190,6 +190,7 @@
#include <cstdint>
#include <optional>
#include <cassert>
#include <numeric>
#ifndef OLC_V2D_TYPE
#define OLC_V2D_TYPE
@ -784,6 +785,11 @@ namespace olc::utils::geom2d
struct polygon
{
std::vector<olc::v_2d<T>> pos;
inline constexpr olc::v_2d<T>middle()const{
vf2d total=std::accumulate(pos.begin(),pos.end(),olc::v_2d<T>{},[](const olc::v_2d<T>&middle,const olc::v_2d<T>&point){return std::move(middle)+point;});
return total/pos.size();
}
};

Loading…
Cancel
Save