Display a message while targeting indicating what the targeting's for

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent e2d23045a7
commit d94382c568
  1. BIN
      C++ProjectTemplate
  2. 30
      main.cpp
  3. 93
      pixelGameEngine.h

Binary file not shown.

@ -162,6 +162,9 @@ public:
int HEALING_OVERWORLD_MEMBER=0; int HEALING_OVERWORLD_MEMBER=0;
bool HEALING_OVERWORLD_SINGLE_MEMBER=false; //When set to true, a single member is being healed. bool HEALING_OVERWORLD_SINGLE_MEMBER=false; //When set to true, a single member is being healed.
bool OVERWORLD_ITEM_BEING_USED=false; //When set to true, we need to equip an item after target selected. bool OVERWORLD_ITEM_BEING_USED=false; //When set to true, we need to equip an item after target selected.
std::string DISPLAY_TARGET_MESSAGE=""; //Display some text while selecting a target.
Key KEY_GENERATE_EVENTS=UP;
float lastPress=0;
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
@ -300,7 +303,14 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
return true; return true;
} }
void GetAnyKey() {
}
void GetAnyKeyPress(olc::Key keypress) override { void GetAnyKeyPress(olc::Key keypress) override {
if (keypress==UP||keypress==DOWN||keypress==RIGHT||keypress==LEFT) {
KEY_GENERATE_EVENTS=keypress;
}
if (messageBoxVisible) { if (messageBoxVisible) {
if (messageBoxMarker==messageBoxFinalText.length()) { if (messageBoxMarker==messageBoxFinalText.length()) {
if (messageBoxStartMarker+messageBoxStopMarker<targetText.length()) { if (messageBoxStartMarker+messageBoxStopMarker<targetText.length()) {
@ -1335,6 +1345,11 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
OVERWORLD_ITEM_BEING_USED=true; OVERWORLD_ITEM_BEING_USED=true;
OVERWORLD_TARGET_SELECTION=0; OVERWORLD_TARGET_SELECTION=0;
PARTY_MEMBER_OBJ[OVERWORLD_TARGET_SELECTION]->highlighted=true; PARTY_MEMBER_OBJ[OVERWORLD_TARGET_SELECTION]->highlighted=true;
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip!=EquipSlot::NONE) {
DISPLAY_TARGET_MESSAGE="Equip "+PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->name+" to...";
} else {
DISPLAY_TARGET_MESSAGE="Use "+PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->name+" on...";
}
} else { } else {
DisplayMessageBox("Cannot use that here."); DisplayMessageBox("Cannot use that here.");
} }
@ -1563,7 +1578,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::OVERWORLD_STATUS_MENU: case GameState::OVERWORLD_STATUS_MENU:
case GameState::OVERWORLD_TARGET_MENU:{ case GameState::OVERWORLD_TARGET_MENU:{
DrawGameWorld(); DrawGameWorld();
if (GAME_STATE!=GameState::GAME_WORLD) { if (GAME_STATE!=GameState::GAME_WORLD&&GAME_STATE!=GameState::OVERWORLD_TARGET_MENU) {
SetDrawTarget(layer::INTERFACE); SetDrawTarget(layer::INTERFACE);
vi2d boxPos = {2,2}; vi2d boxPos = {2,2};
DrawDialogBox(boxPos,{(int)(WIDTH*0.25+4),5*16+4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220)); DrawDialogBox(boxPos,{(int)(WIDTH*0.25+4),5*16+4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
@ -1699,9 +1714,15 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawDecal(BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin()-cameraPos-size/2*scale,SPRITES["targetCircle.png"],scale,YELLOW); DrawDecal(BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin()-cameraPos-size/2*scale,SPRITES["targetCircle.png"],scale,YELLOW);
DrawTargetRangeGrid(BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin(),PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->range); DrawTargetRangeGrid(BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin(),PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->range);
} }
vi2d textPos={2,2};
vi2d shadowOffset={1,1};
SetDrawTarget(layer::INTERFACE);
DrawStringPropDecal(textPos+shadowOffset,DISPLAY_TARGET_MESSAGE,BLACK,{1,2});
DrawStringPropDecal(textPos,DISPLAY_TARGET_MESSAGE,WHITE,{1,2});
} }
if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::ITEM_SELECT||GAME_STATE==GameState::OVERWORLD_ITEMS_MENU&&!messageBoxVisible) { if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::ITEM_SELECT||GAME_STATE==GameState::OVERWORLD_ITEMS_MENU&&!messageBoxVisible) {
SetDrawTarget(layer::INTERFACE);
DrawDialogBox({4,4},{(int)(WIDTH-8),(int)(HEIGHT/2)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220)); DrawDialogBox({4,4},{(int)(WIDTH-8),(int)(HEIGHT/2)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDialogBox({(int)(WIDTH*(3.0F/8)),HEIGHT/2+4},{(int)(WIDTH*(5.0F/8)-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220)); DrawDialogBox({(int)(WIDTH*(3.0F/8)),HEIGHT/2+4},{(int)(WIDTH*(5.0F/8)-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip!=EquipSlot::NONE) { if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip!=EquipSlot::NONE) {
@ -2837,9 +2858,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) { void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
FillRectDecal({(float)(pos.x+3),(float)(pos.y+3)},{(float)(size.x-5),(float)(size.y-5)},p); FillRectDecal({(float)(pos.x+3),(float)(pos.y+3)},{(float)(size.x-5),(float)(size.y-5)},p);
DrawRect({pos.x,pos.y},size,p2); DrawRectDecal({(float)pos.x,(float)pos.y},size,p2);
DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3); DrawRectDecal({(float)pos.x+2,(float)pos.y+2},{(float)size.x-4,(float)size.y-4},p3);
DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2},p); DrawRectDecal({(float)pos.x+1,(float)pos.y+1},{(float)size.x-2,(float)size.y-2},p);
Draw({pos.x,pos.y},olc::BLACK); Draw({pos.x,pos.y},olc::BLACK);
Draw({pos.x+size.x,pos.y+size.y},olc::BLACK); Draw({pos.x+size.x,pos.y+size.y},olc::BLACK);
Draw({pos.x+size.x,pos.y},olc::BLACK); Draw({pos.x+size.x,pos.y},olc::BLACK);
@ -3442,6 +3463,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) { for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true; ent->obj->highlighted=true;
} }
DISPLAY_TARGET_MESSAGE="Use "+PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->GetPowerName()+" on...";
} }
std::vector<Entity*> GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) { std::vector<Entity*> GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) {

@ -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;
} }
} }
@ -3577,7 +3600,7 @@ namespace olc
{ {
fontRenderable.Load("assets/newFont.png"); fontRenderable.Load("assets/newFont.png");
constexpr std::array<uint8_t, 96> vSpacing = { { constexpr std::array<uint8_t, 96> vSpacing = { {
//X position (0-3) offset to display char //X position (0-3) offset to display char
//Y position (0-15) width of the char to display //Y position (0-15) width of the char to display
0x03,0x25,0x16,0x08,0x07,0x08,0x08,0x04,0x15,0x15,0x08,0x07,0x15,0x07,0x24,0x08, 0x03,0x25,0x16,0x08,0x07,0x08,0x08,0x04,0x15,0x15,0x08,0x07,0x15,0x07,0x24,0x08,

Loading…
Cancel
Save