|
|
|
@ -2,12 +2,10 @@ |
|
|
|
|
olcPixelGameEngine.h |
|
|
|
|
|
|
|
|
|
+-------------------------------------------------------------+ |
|
|
|
|
| OneLoneCoder Pixel Game Engine v1.11 | |
|
|
|
|
| OneLoneCoder Pixel Game Engine v1.12 | |
|
|
|
|
| "Like the command prompt console one, but not..." - javidx9 | |
|
|
|
|
+-------------------------------------------------------------+ |
|
|
|
|
|
|
|
|
|
The Original & Best... :P |
|
|
|
|
|
|
|
|
|
What is this? |
|
|
|
|
~~~~~~~~~~~~~ |
|
|
|
|
The olcConsoleGameEngine has been a surprsing and wonderful |
|
|
|
@ -90,6 +88,7 @@ |
|
|
|
|
Twitch: https://www.twitch.tv/javidx9
|
|
|
|
|
GitHub: https://www.github.com/onelonecoder
|
|
|
|
|
Homepage: https://www.onelonecoder.com
|
|
|
|
|
Patreon: https://www.patreon.com/javidx9
|
|
|
|
|
|
|
|
|
|
Relevant Videos |
|
|
|
|
~~~~~~~~~~~~~~~ |
|
|
|
@ -121,17 +120,20 @@ |
|
|
|
|
~~~~~~ |
|
|
|
|
I'd like to extend thanks to Eremiell, slavka, gurkanctn, Phantim,
|
|
|
|
|
JackOJC, KrossX, Huhlig, Dragoneye, Appa, JustinRichardsMusic, SliceNDice |
|
|
|
|
& MagetzUb for advice, ideas and testing, and I'd like to extend
|
|
|
|
|
my appreciation to the 14K YouTube followers and 1K Discord server |
|
|
|
|
Ralakus, Gorbit99, raoul & MagetzUb for advice, ideas and testing, and I'd like
|
|
|
|
|
to extend my appreciation to the 23K YouTube followers and 1.5K Discord server |
|
|
|
|
members who give me the motivation to keep going with all this :D |
|
|
|
|
|
|
|
|
|
Special thanks to those who bring gifts! |
|
|
|
|
GnarGnarHead.......Domina |
|
|
|
|
Gorbit99...........Bastion |
|
|
|
|
|
|
|
|
|
Special thanks to my Patreons too - I wont name you on here, but I've |
|
|
|
|
certainly enjoyed my tea and flapjacks :D |
|
|
|
|
|
|
|
|
|
Author |
|
|
|
|
~~~~~~
|
|
|
|
|
David Barr, aka javidx9, ©OneLoneCoder 2018 |
|
|
|
|
David Barr, aka javidx9, ©OneLoneCoder 2018, 2019 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ -279,7 +281,8 @@ namespace olc // All OneLoneCoder stuff will now exist in the "olc" namespace |
|
|
|
|
ResourcePack(); |
|
|
|
|
~ResourcePack(); |
|
|
|
|
struct sEntry : public std::streambuf { |
|
|
|
|
uint32_t nID, nFileOffset, nFileSize; uint8_t* data; void _config() { this->setg((char*)data, (char*)data, (char*)(data + nFileSize)); }}; |
|
|
|
|
uint32_t nID, nFileOffset, nFileSize; uint8_t* data; void _config() { this->setg((char*)data, (char*)data, (char*)(data + nFileSize)); } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
olc::rcode AddToPack(std::string sFile); |
|
|
|
@ -346,7 +349,9 @@ namespace olc // All OneLoneCoder stuff will now exist in the "olc" namespace |
|
|
|
|
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, |
|
|
|
|
UP, DOWN, LEFT, RIGHT, |
|
|
|
|
SPACE, TAB, SHIFT, CTRL, INS, DEL, HOME, END, PGUP, PGDN, |
|
|
|
|
BACK, ESCAPE, ENTER, PAUSE, SCROLL, |
|
|
|
|
BACK, ESCAPE, RETURN, ENTER, PAUSE, SCROLL, |
|
|
|
|
NP0, NP1, NP2, NP3, NP4, NP5, NP6, NP7, NP8, NP9, |
|
|
|
|
NP_MUL, NP_DIV, NP_ADD, NP_SUB, NP_DECIMAL, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -402,6 +407,7 @@ namespace olc // All OneLoneCoder stuff will now exist in the "olc" namespace |
|
|
|
|
// olc::Pixel::MASK = Transparent if alpha is < 255
|
|
|
|
|
// olc::Pixel::ALPHA = Full transparency
|
|
|
|
|
void SetPixelMode(Pixel::Mode m); |
|
|
|
|
Pixel::Mode GetPixelMode(); |
|
|
|
|
// Use a custom blend function
|
|
|
|
|
void SetPixelMode(std::function<olc::Pixel(const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest)> pixelMode); |
|
|
|
|
// Change the blend factor form between 0.0f to 1.0f;
|
|
|
|
@ -647,7 +653,8 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
std::istream is(&(pack->GetStreamBuffer(sImageFile))); |
|
|
|
|
auto streamBuffer = pack->GetStreamBuffer(sImageFile); |
|
|
|
|
std::istream is(&streamBuffer); |
|
|
|
|
ReadData(is); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -852,10 +859,10 @@ namespace olc |
|
|
|
|
// Create entry
|
|
|
|
|
sEntry e; |
|
|
|
|
e.data = nullptr; |
|
|
|
|
e.nFileSize = p; |
|
|
|
|
e.nFileSize = (uint32_t)p; |
|
|
|
|
|
|
|
|
|
// Read file into memory
|
|
|
|
|
e.data = new uint8_t[e.nFileSize]; |
|
|
|
|
e.data = new uint8_t[(uint32_t)e.nFileSize]; |
|
|
|
|
ifs.read((char*)e.data, e.nFileSize); |
|
|
|
|
ifs.close(); |
|
|
|
|
|
|
|
|
@ -886,7 +893,7 @@ namespace olc |
|
|
|
|
std::streampos offset = ofs.tellp(); |
|
|
|
|
for (auto &e : mapFiles) |
|
|
|
|
{ |
|
|
|
|
e.second.nFileOffset = offset; |
|
|
|
|
e.second.nFileOffset = (uint32_t)offset; |
|
|
|
|
ofs.write((char*)e.second.data, e.second.nFileSize); |
|
|
|
|
offset += e.second.nFileSize; |
|
|
|
|
} |
|
|
|
@ -936,12 +943,10 @@ namespace olc |
|
|
|
|
// 2) Read Data
|
|
|
|
|
for (auto &e : mapFiles) |
|
|
|
|
{ |
|
|
|
|
e.second.data = new uint8_t[e.second.nFileSize]; |
|
|
|
|
e.second.data = new uint8_t[(uint32_t)e.second.nFileSize]; |
|
|
|
|
ifs.seekg(e.second.nFileOffset); |
|
|
|
|
ifs.read((char*)e.second.data, e.second.nFileSize); |
|
|
|
|
//e.second.setg
|
|
|
|
|
e.second._config(); |
|
|
|
|
//e.second.pubsetbuf((char*)e.second.data, e.second.nFileSize);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ifs.close(); |
|
|
|
@ -1542,6 +1547,11 @@ namespace olc |
|
|
|
|
nPixelMode = m; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel::Mode PixelGameEngine::GetPixelMode() |
|
|
|
|
{ |
|
|
|
|
return nPixelMode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetPixelMode(std::function<olc::Pixel(const int x, const int y, const olc::Pixel&, const olc::Pixel&)> pixelMode) |
|
|
|
|
{ |
|
|
|
|
funcPixelMode = pixelMode; |
|
|
|
@ -1884,6 +1894,7 @@ namespace olc |
|
|
|
|
mapKeys[VK_F9] = Key::F9; mapKeys[VK_F10] = Key::F10; mapKeys[VK_F11] = Key::F11; mapKeys[VK_F12] = Key::F12; |
|
|
|
|
|
|
|
|
|
mapKeys[VK_DOWN] = Key::DOWN; mapKeys[VK_LEFT] = Key::LEFT; mapKeys[VK_RIGHT] = Key::RIGHT; mapKeys[VK_UP] = Key::UP; |
|
|
|
|
mapKeys[VK_RETURN] = Key::ENTER; //mapKeys[VK_RETURN] = Key::RETURN;
|
|
|
|
|
|
|
|
|
|
mapKeys[VK_BACK] = Key::BACK; mapKeys[VK_ESCAPE] = Key::ESCAPE; mapKeys[VK_RETURN] = Key::ENTER; mapKeys[VK_PAUSE] = Key::PAUSE; |
|
|
|
|
mapKeys[VK_SCROLL] = Key::SCROLL; mapKeys[VK_TAB] = Key::TAB; mapKeys[VK_DELETE] = Key::DEL; mapKeys[VK_HOME] = Key::HOME; |
|
|
|
@ -1894,6 +1905,10 @@ namespace olc |
|
|
|
|
mapKeys[0x30] = Key::K0; mapKeys[0x31] = Key::K1; mapKeys[0x32] = Key::K2; mapKeys[0x33] = Key::K3; mapKeys[0x34] = Key::K4; |
|
|
|
|
mapKeys[0x35] = Key::K5; mapKeys[0x36] = Key::K6; mapKeys[0x37] = Key::K7; mapKeys[0x38] = Key::K8; mapKeys[0x39] = Key::K9; |
|
|
|
|
|
|
|
|
|
mapKeys[VK_NUMPAD0] = Key::NP0; mapKeys[VK_NUMPAD1] = Key::NP1; mapKeys[VK_NUMPAD2] = Key::NP2; mapKeys[VK_NUMPAD3] = Key::NP3; mapKeys[VK_NUMPAD4] = Key::NP4; |
|
|
|
|
mapKeys[VK_NUMPAD5] = Key::NP5; mapKeys[VK_NUMPAD6] = Key::NP6; mapKeys[VK_NUMPAD7] = Key::NP7; mapKeys[VK_NUMPAD8] = Key::NP8; mapKeys[VK_NUMPAD9] = Key::NP9; |
|
|
|
|
mapKeys[VK_MULTIPLY] = Key::NP_MUL; mapKeys[VK_ADD] = Key::NP_ADD; mapKeys[VK_DIVIDE] = Key::NP_DIV; mapKeys[VK_SUBTRACT] = Key::NP_SUB; mapKeys[VK_DECIMAL] = Key::NP_DECIMAL; |
|
|
|
|
|
|
|
|
|
return olc_hWnd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1995,6 +2010,7 @@ namespace olc |
|
|
|
|
mapKeys[XK_F9] = Key::F9; mapKeys[XK_F10] = Key::F10; mapKeys[XK_F11] = Key::F11; mapKeys[XK_F12] = Key::F12; |
|
|
|
|
|
|
|
|
|
mapKeys[XK_Down] = Key::DOWN; mapKeys[XK_Left] = Key::LEFT; mapKeys[XK_Right] = Key::RIGHT; mapKeys[XK_Up] = Key::UP; |
|
|
|
|
mapKeys[XK_KP_Enter] = Key::ENTER; mapKeys[XK_Return] = Key::ENTER; |
|
|
|
|
|
|
|
|
|
mapKeys[XK_BackSpace] = Key::BACK; mapKeys[XK_Escape] = Key::ESCAPE; mapKeys[XK_Linefeed] = Key::ENTER; mapKeys[XK_Pause] = Key::PAUSE; |
|
|
|
|
mapKeys[XK_Scroll_Lock] = Key::SCROLL; mapKeys[XK_Tab] = Key::TAB; mapKeys[XK_Delete] = Key::DEL; mapKeys[XK_Home] = Key::HOME; |
|
|
|
@ -2005,6 +2021,10 @@ namespace olc |
|
|
|
|
mapKeys[XK_0] = Key::K0; mapKeys[XK_1] = Key::K1; mapKeys[XK_2] = Key::K2; mapKeys[XK_3] = Key::K3; mapKeys[XK_4] = Key::K4; |
|
|
|
|
mapKeys[XK_5] = Key::K5; mapKeys[XK_6] = Key::K6; mapKeys[XK_7] = Key::K7; mapKeys[XK_8] = Key::K8; mapKeys[XK_9] = Key::K9; |
|
|
|
|
|
|
|
|
|
mapKeys[XK_KP_0] = Key::NP0; mapKeys[XK_KP_1] = Key::NP1; mapKeys[XK_KP_2] = Key::NP2; mapKeys[XK_KP_3] = Key::NP3; mapKeys[XK_KP_4] = Key::NP4; |
|
|
|
|
mapKeys[XK_KP_5] = Key::NP5; mapKeys[XK_KP_6] = Key::NP6; mapKeys[XK_KP_7] = Key::NP7; mapKeys[XK_KP_8] = Key::NP8; mapKeys[XK_KP_9] = Key::NP9; |
|
|
|
|
mapKeys[XK_KP_Multiply] = Key::NP_MUL; mapKeys[XK_KP_Add] = Key::NP_ADD; mapKeys[XK_KP_Divide] = Key::NP_DIV; mapKeys[XK_KP_Subtract] = Key::NP_SUB; mapKeys[XK_KP_Decimal] = Key::NP_DECIMAL; |
|
|
|
|
|
|
|
|
|
return olc_Display; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|