Update PGE header

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent adc9296171
commit c1ab45ff3f
  1. 2
      .vscode/launch.json
  2. BIN
      C++ProjectTemplate
  3. BIN
      a.out
  4. 1244
      main.cpp
  5. 91
      pixelGameEngine.h
  6. 2
      sig

@ -8,7 +8,7 @@
"name": "(gdb) Launch", "name": "(gdb) Launch",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/a.out", "program": "${workspaceFolder}/C++ProjectTemplate",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${fileDirname}", "cwd": "${fileDirname}",

Binary file not shown.

BIN
a.out

Binary file not shown.

1244
main.cpp

File diff suppressed because it is too large Load Diff

@ -3,7 +3,7 @@
olcPixelGameEngine.h olcPixelGameEngine.h
+-------------------------------------------------------------+ +-------------------------------------------------------------+
| OneLoneCoder Pixel Game Engine v2.19 | | OneLoneCoder Pixel Game Engine v2.20 |
| "What do you need? Pixels... Lots of Pixels..." - javidx9 | | "What do you need? Pixels... Lots of Pixels..." - javidx9 |
+-------------------------------------------------------------+ +-------------------------------------------------------------+
@ -187,6 +187,8 @@
AlterEgo...........Final Fantasy XII - The Zodiac Age AlterEgo...........Final Fantasy XII - The Zodiac Age
SlicEnDicE.........Noita, Inside SlicEnDicE.........Noita, Inside
TGD................Voucher Gift TGD................Voucher Gift
Dragoneye..........Lucas Arts Adventure Game Pack
Anonymous Pirate...Return To Monkey Island
Special thanks to my Patreons too - I wont name you on here, but I've Special thanks to my Patreons too - I wont name you on here, but I've
certainly enjoyed my tea and flapjacks :D certainly enjoyed my tea and flapjacks :D
@ -297,9 +299,16 @@
+ConsoleClear() - Clears built in command console output +ConsoleClear() - Clears built in command console output
+ConsoleOut() - Stream strings to command console output +ConsoleOut() - Stream strings to command console output
+ConsoleCaptureStdOut() - Capture std::cout by redirecting to built-in console +ConsoleCaptureStdOut() - Capture std::cout by redirecting to built-in console
+IsConsoleShowing() - Returns true if console is currently active
+OnConsoleCommand() - Override is called when command is entered into built in console +OnConsoleCommand() - Override is called when command is entered into built in console
2.20: +DrawRectDecal() - Keeps OneSketchyGuy quiet
+GetScreenSize()
+olc::Sprite::Size() - returns size of sprite in vector format
SIG Updates:
The following additions are included in Sig's version of the PGE header (this is a sig version)
+GetAnyKey() - Returns when a key is activated
+GetAnyKeyPress() - Returns when a key is pressed down (and if a keyboard key, which key it was)
!! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !! !! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !!
!! Volunteers willing to help appreciated, though PRs are manually integrated with credit !! !! Volunteers willing to help appreciated, though PRs are manually integrated with credit !!
*/ */
@ -378,7 +387,7 @@ int main()
#include <cstring> #include <cstring>
#pragma endregion #pragma endregion
#define PGE_VER 219 #define PGE_VER 220
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
// | COMPILER CONFIGURATION ODDITIES | // | COMPILER CONFIGURATION ODDITIES |
@ -771,6 +780,7 @@ namespace olc
Pixel* GetData(); Pixel* GetData();
olc::Sprite* Duplicate(); olc::Sprite* Duplicate();
olc::Sprite* Duplicate(const olc::vi2d& vPos, const olc::vi2d& vSize); olc::Sprite* Duplicate(const olc::vi2d& vPos, const olc::vi2d& vSize);
olc::vi2d Size() const;
std::vector<olc::Pixel> pColData; std::vector<olc::Pixel> pColData;
Mode modeSample = Mode::NORMAL; Mode modeSample = Mode::NORMAL;
@ -982,6 +992,8 @@ namespace olc
const olc::vi2d& GetPixelSize() const; const olc::vi2d& GetPixelSize() const;
// Gets actual pixel scale // Gets actual pixel scale
const olc::vi2d& GetScreenPixelSize() const; const olc::vi2d& GetScreenPixelSize() const;
// Gets "screen" size
const olc::vi2d& GetScreenSize() const;
public: // CONFIGURATION ROUTINES public: // CONFIGURATION ROUTINES
// Layer targeting functions // Layer targeting functions
@ -1076,6 +1088,7 @@ namespace olc
void DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
void DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
// Draws a single shaded filled rectangle as a decal // Draws a single shaded filled rectangle as a decal
void DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
void FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE); void FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
// Draws a corner shaded rectangle as a decal // Draws a corner shaded rectangle as a decal
void GradientFillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR); void GradientFillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR);
@ -1086,7 +1099,6 @@ namespace olc
// Draws a line in Decal Space // Draws a line in Decal Space
void DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE); void DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE);
void DrawRectDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE);
void DrawRotatedStringDecal(const olc::vf2d& pos, const std::string& sText, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawRotatedStringDecal(const olc::vf2d& pos, const std::string& sText, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
void DrawRotatedStringPropDecal(const olc::vf2d& pos, const std::string& sText, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); void DrawRotatedStringPropDecal(const olc::vf2d& pos, const std::string& sText, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
// Clears entire draw target to Pixel // Clears entire draw target to Pixel
@ -1114,7 +1126,6 @@ namespace olc
std::string TextEntryGetString() const; std::string TextEntryGetString() const;
int32_t TextEntryGetCursor() const; int32_t TextEntryGetCursor() const;
bool IsTextEntryEnabled() const; bool IsTextEntryEnabled() const;
void SetFPSDisplay(bool display);
@ -1152,7 +1163,6 @@ namespace olc
#endif #endif
public: // Branding public: // Branding
std::string sAppName; std::string sAppName;
Renderable fontRenderable;
private: // Inner mysterious workings private: // Inner mysterious workings
olc::Sprite* pDrawTarget = nullptr; olc::Sprite* pDrawTarget = nullptr;
@ -1178,8 +1188,8 @@ namespace olc
float fFrameTimer = 1.0f; float fFrameTimer = 1.0f;
float fLastElapsed = 0.0f; float fLastElapsed = 0.0f;
int nFrameCount = 0; int nFrameCount = 0;
bool showFPS = true;
bool bSuspendTextureTransfer = false; bool bSuspendTextureTransfer = false;
Renderable fontRenderable;
std::vector<LayerDesc> vLayers; std::vector<LayerDesc> vLayers;
uint8_t nTargetLayer = 0; uint8_t nTargetLayer = 0;
uint32_t nLastFPS = 0; uint32_t nLastFPS = 0;
@ -1511,6 +1521,11 @@ namespace olc
return spr; return spr;
} }
olc::vi2d olc::Sprite::Size() const
{
return { width, height };
}
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
// | olc::Decal IMPLEMENTATION | // | olc::Decal IMPLEMENTATION |
// O------------------------------------------------------------------------------O // O------------------------------------------------------------------------------O
@ -1947,6 +1962,9 @@ namespace olc
const olc::vi2d& PixelGameEngine::GetScreenPixelSize() const const olc::vi2d& PixelGameEngine::GetScreenPixelSize() const
{ return vScreenPixelSize; } { return vScreenPixelSize; }
const olc::vi2d& PixelGameEngine::GetScreenSize() const
{ return vScreenSize; }
const olc::vi2d& PixelGameEngine::GetWindowMouse() const const olc::vi2d& PixelGameEngine::GetWindowMouse() const
{ return vMouseWindowPos; } { return vMouseWindowPos; }
@ -2670,7 +2688,12 @@ namespace olc
void PixelGameEngine::DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p) void PixelGameEngine::DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p)
{ {
DecalInstance di; auto m = nDecalMode;
nDecalMode = olc::DecalMode::WIREFRAME;
DrawPolygonDecal(nullptr, { pos1, pos2 }, { {0, 0}, {0,0} }, p);
nDecalMode = m;
/*DecalInstance di;
di.decal = nullptr; di.decal = nullptr;
di.points = uint32_t(2); di.points = uint32_t(2);
di.pos.resize(di.points); di.pos.resize(di.points);
@ -2686,19 +2709,26 @@ namespace olc
di.tint[1] = p; di.tint[1] = p;
di.w[1] = 1.0f; di.w[1] = 1.0f;
di.mode = olc::DecalMode::WIREFRAME; di.mode = olc::DecalMode::WIREFRAME;
vLayers[nTargetLayer].vecDecalInstance.push_back(di); di.structure = nDecalStructure;
vLayers[nTargetLayer].vecDecalInstance.push_back(di);*/
} }
void PixelGameEngine::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col) { void PixelGameEngine::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)
DrawLineDecal(pos,{pos.x+size.x,pos.y},col); {
DrawLineDecal({pos.x,pos.y},{pos.x,pos.y+size.y},col); auto m = nDecalMode;
DrawLineDecal({pos.x,pos.y+size.y},{pos.x+size.x,pos.y+size.y},col); SetDecalMode(olc::DecalMode::WIREFRAME);
DrawLineDecal({pos.x+size.x,pos.y},{pos.x+size.x,pos.y+size.y},col); olc::vf2d vNewSize = size;// (size - olc::vf2d(0.375f, 0.375f)).ceil();
std::array<olc::vf2d, 4> points = { { {pos}, {pos.x, pos.y + vNewSize.y}, {pos + vNewSize}, {pos.x + vNewSize.x, pos.y} } };
std::array<olc::vf2d, 4> uvs = { {{0,0},{0,0},{0,0},{0,0}} };
std::array<olc::Pixel, 4> cols = { {col, col, col, col} };
DrawExplicitDecal(nullptr, points.data(), uvs.data(), cols.data(), 4);
SetDecalMode(m);
} }
void PixelGameEngine::FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col) void PixelGameEngine::FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)
{ {
olc::vf2d vNewSize = (size - olc::vf2d(0.375f, 0.375f)).ceil(); olc::vf2d vNewSize = size;// (size - olc::vf2d(0.375f, 0.375f)).ceil();
std::array<olc::vf2d, 4> points = { { {pos}, {pos.x, pos.y + vNewSize.y}, {pos + vNewSize}, {pos.x + vNewSize.x, pos.y} } }; std::array<olc::vf2d, 4> points = { { {pos}, {pos.x, pos.y + vNewSize.y}, {pos + vNewSize}, {pos.x + vNewSize.x, pos.y} } };
std::array<olc::vf2d, 4> uvs = { {{0,0},{0,0},{0,0},{0,0}} }; std::array<olc::vf2d, 4> uvs = { {{0,0},{0,0},{0,0},{0,0}} };
std::array<olc::Pixel, 4> cols = { {col, col, col, col} }; std::array<olc::Pixel, 4> cols = { {col, col, col, col} };
@ -3211,9 +3241,6 @@ namespace olc
bool PixelGameEngine::IsTextEntryEnabled() const bool PixelGameEngine::IsTextEntryEnabled() const
{ return bTextEntryEnable; } { return bTextEntryEnable; }
void PixelGameEngine::SetFPSDisplay(bool display)
{ showFPS=display; }
void PixelGameEngine::UpdateTextEntry() void PixelGameEngine::UpdateTextEntry()
{ {
@ -3481,11 +3508,12 @@ namespace olc
} }
if (pressed) { if (pressed) {
if (keyboard) {GetAnyKeyPress((olc::Key)key);} if (keyboard) {GetAnyKeyPress((olc::Key)key);}
else {GetAnyKeyPress(olc::Key::NONE);}} else {GetAnyKeyPress(olc::Key::NONE);}
}
}; };
ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256); ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256);
ScanHardware(pMouseState, pMouseOldState, pMouseNewState, nMouseButtons,false); ScanHardware(pMouseState, pMouseOldState, pMouseNewState, nMouseButtons, false);
// Cache mouse coordinates so they remain consistent during frame // Cache mouse coordinates so they remain consistent during frame
vMousePos = vMousePosCache; vMousePos = vMousePosCache;
@ -3555,21 +3583,16 @@ namespace olc
// Present Graphics to screen // Present Graphics to screen
renderer->DisplayFrame(); renderer->DisplayFrame();
if (showFPS) { // Update Title Bar
// Update Title Bar fFrameTimer += fElapsedTime;
fFrameTimer += fElapsedTime; nFrameCount++;
nFrameCount++; if (fFrameTimer >= 1.0f)
if (fFrameTimer >= 1.0f) {
{ nLastFPS = nFrameCount;
nLastFPS = nFrameCount; fFrameTimer -= 1.0f;
fFrameTimer -= 1.0f; std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + " - FPS: " + std::to_string(nFrameCount);
std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + " - FPS: " + std::to_string(nFrameCount);
platform->SetWindowTitle(sTitle);
nFrameCount = 0;
}
} else {
std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName;
platform->SetWindowTitle(sTitle); platform->SetWindowTitle(sTitle);
nFrameCount = 0;
} }
} }

2
sig

@ -1,4 +1,4 @@
export AUTO_UPDATE=true export AUTO_UPDATE=false
source utils/define.sh source utils/define.sh

Loading…
Cancel
Save