diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 1b2c06e..dd48660 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 5ff5817..a76e8ec 100644 --- a/main.cpp +++ b/main.cpp @@ -162,6 +162,9 @@ public: int HEALING_OVERWORLD_MEMBER=0; 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. + 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. @@ -300,7 +303,14 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"), return true; } + void GetAnyKey() { + + } + void GetAnyKeyPress(olc::Key keypress) override { + if (keypress==UP||keypress==DOWN||keypress==RIGHT||keypress==LEFT) { + KEY_GENERATE_EVENTS=keypress; + } if (messageBoxVisible) { if (messageBoxMarker==messageBoxFinalText.length()) { if (messageBoxStartMarker+messageBoxStopMarkerhighlighted=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 { 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_TARGET_MENU:{ DrawGameWorld(); - if (GAME_STATE!=GameState::GAME_WORLD) { + if (GAME_STATE!=GameState::GAME_WORLD&&GAME_STATE!=GameState::OVERWORLD_TARGET_MENU) { SetDrawTarget(layer::INTERFACE); 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)); @@ -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); 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) { + 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({(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) { @@ -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) { 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); - DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3); - DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2},p); + DrawRectDecal({(float)pos.x,(float)pos.y},size,p2); + DrawRectDecal({(float)pos.x+2,(float)pos.y+2},{(float)size.x-4,(float)size.y-4},p3); + 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+size.x,pos.y+size.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)) { ent->obj->highlighted=true; } + DISPLAY_TARGET_MESSAGE="Use "+PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->GetPowerName()+" on..."; } std::vector GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) { diff --git a/pixelGameEngine.h b/pixelGameEngine.h index 92ea242..97cf2db 100644 --- a/pixelGameEngine.h +++ b/pixelGameEngine.h @@ -3,7 +3,7 @@ olcPixelGameEngine.h +-------------------------------------------------------------+ - | OneLoneCoder Pixel Game Engine v2.19 | + | OneLoneCoder Pixel Game Engine v2.20 | | "What do you need? Pixels... Lots of Pixels..." - javidx9 | +-------------------------------------------------------------+ @@ -187,6 +187,8 @@ AlterEgo...........Final Fantasy XII - The Zodiac Age SlicEnDicE.........Noita, Inside 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 certainly enjoyed my tea and flapjacks :D @@ -297,9 +299,16 @@ +ConsoleClear() - Clears built in command console output +ConsoleOut() - Stream strings to command console output +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 + 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... !! !! Volunteers willing to help appreciated, though PRs are manually integrated with credit !! */ @@ -378,7 +387,7 @@ int main() #include #pragma endregion -#define PGE_VER 219 +#define PGE_VER 220 // O------------------------------------------------------------------------------O // | COMPILER CONFIGURATION ODDITIES | @@ -771,6 +780,7 @@ namespace olc Pixel* GetData(); olc::Sprite* Duplicate(); olc::Sprite* Duplicate(const olc::vi2d& vPos, const olc::vi2d& vSize); + olc::vi2d Size() const; std::vector pColData; Mode modeSample = Mode::NORMAL; @@ -982,6 +992,8 @@ namespace olc const olc::vi2d& GetPixelSize() const; // Gets actual pixel scale const olc::vi2d& GetScreenPixelSize() const; + // Gets "screen" size + const olc::vi2d& GetScreenSize() const; public: // CONFIGURATION ROUTINES // 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 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 + 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); // 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); @@ -1086,7 +1099,6 @@ namespace olc // Draws a line in Decal Space 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 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 @@ -1114,7 +1126,6 @@ namespace olc std::string TextEntryGetString() const; int32_t TextEntryGetCursor() const; bool IsTextEntryEnabled() const; - void SetFPSDisplay(bool display); @@ -1152,7 +1163,6 @@ namespace olc #endif public: // Branding std::string sAppName; - Renderable fontRenderable; private: // Inner mysterious workings olc::Sprite* pDrawTarget = nullptr; @@ -1178,8 +1188,8 @@ namespace olc float fFrameTimer = 1.0f; float fLastElapsed = 0.0f; int nFrameCount = 0; - bool showFPS = true; bool bSuspendTextureTransfer = false; + Renderable fontRenderable; std::vector vLayers; uint8_t nTargetLayer = 0; uint32_t nLastFPS = 0; @@ -1511,6 +1521,11 @@ namespace olc return spr; } + olc::vi2d olc::Sprite::Size() const + { + return { width, height }; + } + // O------------------------------------------------------------------------------O // | olc::Decal IMPLEMENTATION | // O------------------------------------------------------------------------------O @@ -1947,6 +1962,9 @@ namespace olc const olc::vi2d& PixelGameEngine::GetScreenPixelSize() const { return vScreenPixelSize; } + const olc::vi2d& PixelGameEngine::GetScreenSize() const + { return vScreenSize; } + const olc::vi2d& PixelGameEngine::GetWindowMouse() const { return vMouseWindowPos; } @@ -2670,7 +2688,12 @@ namespace olc 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.points = uint32_t(2); di.pos.resize(di.points); @@ -2686,19 +2709,26 @@ namespace olc di.tint[1] = p; di.w[1] = 1.0f; 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) { - DrawLineDecal(pos,{pos.x+size.x,pos.y},col); - DrawLineDecal({pos.x,pos.y},{pos.x,pos.y+size.y},col); - DrawLineDecal({pos.x,pos.y+size.y},{pos.x+size.x,pos.y+size.y},col); - DrawLineDecal({pos.x+size.x,pos.y},{pos.x+size.x,pos.y+size.y},col); + void PixelGameEngine::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col) + { + auto m = nDecalMode; + SetDecalMode(olc::DecalMode::WIREFRAME); + olc::vf2d vNewSize = size;// (size - olc::vf2d(0.375f, 0.375f)).ceil(); + std::array points = { { {pos}, {pos.x, pos.y + vNewSize.y}, {pos + vNewSize}, {pos.x + vNewSize.x, pos.y} } }; + std::array uvs = { {{0,0},{0,0},{0,0},{0,0}} }; + std::array 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) { - 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 points = { { {pos}, {pos.x, pos.y + vNewSize.y}, {pos + vNewSize}, {pos.x + vNewSize.x, pos.y} } }; std::array uvs = { {{0,0},{0,0},{0,0},{0,0}} }; std::array cols = { {col, col, col, col} }; @@ -3211,9 +3241,6 @@ namespace olc bool PixelGameEngine::IsTextEntryEnabled() const { return bTextEntryEnable; } - void PixelGameEngine::SetFPSDisplay(bool display) - { showFPS=display; } - void PixelGameEngine::UpdateTextEntry() { @@ -3481,11 +3508,12 @@ namespace olc } if (pressed) { if (keyboard) {GetAnyKeyPress((olc::Key)key);} - else {GetAnyKeyPress(olc::Key::NONE);}} + else {GetAnyKeyPress(olc::Key::NONE);} + } }; 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 vMousePos = vMousePosCache; @@ -3555,21 +3583,16 @@ namespace olc // Present Graphics to screen renderer->DisplayFrame(); - if (showFPS) { - // Update Title Bar - fFrameTimer += fElapsedTime; - nFrameCount++; - if (fFrameTimer >= 1.0f) - { - nLastFPS = nFrameCount; - fFrameTimer -= 1.0f; - 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; + // Update Title Bar + fFrameTimer += fElapsedTime; + nFrameCount++; + if (fFrameTimer >= 1.0f) + { + nLastFPS = nFrameCount; + fFrameTimer -= 1.0f; + std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + " - FPS: " + std::to_string(nFrameCount); platform->SetWindowTitle(sTitle); + nFrameCount = 0; } } @@ -3577,7 +3600,7 @@ namespace olc { fontRenderable.Load("assets/newFont.png"); - constexpr std::array vSpacing = { { + constexpr std::array vSpacing = { { //X position (0-3) offset to display char //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,