|
|
@ -289,12 +289,17 @@ public: |
|
|
|
Create(w, h); |
|
|
|
Create(w, h); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
olcSprite(std::string sFile) |
|
|
|
olcSprite(std::wstring sFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!Load(sFile)) |
|
|
|
if (!Load(sFile)) |
|
|
|
Create(8, 8); |
|
|
|
Create(8, 8); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~olcSprite() { |
|
|
|
|
|
|
|
delete[] m_Glyphs; |
|
|
|
|
|
|
|
delete[] m_Colours; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int nWidth = 0; |
|
|
|
int nWidth = 0; |
|
|
|
int nHeight = 0; |
|
|
|
int nHeight = 0; |
|
|
|
|
|
|
|
|
|
|
@ -372,7 +377,11 @@ public: |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::string path(sFile.begin(), sFile.end()); |
|
|
|
std::string path(sFile.begin(), sFile.end()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __APPLE__ |
|
|
|
std::ofstream f(path.c_str(), std::ios::out | std::ios::binary); |
|
|
|
std::ofstream f(path.c_str(), std::ios::out | std::ios::binary); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
std::ofstream f(sFile.c_str(), std::ios::out | std::ios::binary); |
|
|
|
|
|
|
|
#endif |
|
|
|
if (!f.is_open()) return false; |
|
|
|
if (!f.is_open()) return false; |
|
|
|
|
|
|
|
|
|
|
|
f.write((char*)&nWidth, sizeof(int)); |
|
|
|
f.write((char*)&nWidth, sizeof(int)); |
|
|
@ -394,7 +403,11 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
std::string path(sFile.begin(), sFile.end()); |
|
|
|
std::string path(sFile.begin(), sFile.end()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __APPLE__ |
|
|
|
std::ifstream f(path.c_str(), std::ios::in | std::ios::binary); |
|
|
|
std::ifstream f(path.c_str(), std::ios::in | std::ios::binary); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
std::ifstream f(sFile.c_str(), std::ios::in | std::ios::binary); |
|
|
|
|
|
|
|
#endif |
|
|
|
if (!f.is_open()) return false; |
|
|
|
if (!f.is_open()) return false; |
|
|
|
|
|
|
|
|
|
|
|
// get file data
|
|
|
|
// get file data
|
|
|
@ -706,7 +719,6 @@ public: |
|
|
|
// Start the thread
|
|
|
|
// Start the thread
|
|
|
|
//std::thread t = std::thread(&olcConsoleGameEngine::GameThread, this);
|
|
|
|
//std::thread t = std::thread(&olcConsoleGameEngine::GameThread, this);
|
|
|
|
GameThread(); |
|
|
|
GameThread(); |
|
|
|
|
|
|
|
|
|
|
|
// Wait for thread to be exited
|
|
|
|
// Wait for thread to be exited
|
|
|
|
//t.join();
|
|
|
|
//t.join();
|
|
|
|
} |
|
|
|
} |
|
|
@ -738,7 +750,6 @@ private: |
|
|
|
#else |
|
|
|
#else |
|
|
|
wcstombs(bufAppName, m_sAppName.c_str(), 256); |
|
|
|
wcstombs(bufAppName, m_sAppName.c_str(), 256); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Create Window
|
|
|
|
// Create Window
|
|
|
|
m_window = SDL_CreateWindow( |
|
|
|
m_window = SDL_CreateWindow( |
|
|
|
bufAppName, |
|
|
|
bufAppName, |
|
|
@ -908,79 +919,6 @@ private: |
|
|
|
m_mouseOldState[m] = m_mouseNewState[m]; |
|
|
|
m_mouseOldState[m] = m_mouseNewState[m]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Handle Mouse Input - Check for window events
|
|
|
|
|
|
|
|
/* INPUT_RECORD inBuf[32];
|
|
|
|
|
|
|
|
DWORD events = 0; |
|
|
|
|
|
|
|
GetNumberOfConsoleInputEvents(m_hConsoleIn, &events); |
|
|
|
|
|
|
|
if (events > 0) |
|
|
|
|
|
|
|
ReadConsoleInput(m_hConsoleIn, inBuf, events, &events);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle events - we only care about mouse clicks and movement
|
|
|
|
|
|
|
|
// for now
|
|
|
|
|
|
|
|
//for (DWORD i = 0; i < events; i++)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// switch (inBuf[i].EventType)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// case FOCUS_EVENT:
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// m_bConsoleInFocus = inBuf[i].Event.FocusEvent.bSetFocus;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// case MOUSE_EVENT:
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// switch (inBuf[i].Event.MouseEvent.dwEventFlags)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// case MOUSE_MOVED:
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// m_mousePosX = inBuf[i].Event.MouseEvent.dwMousePosition.X;
|
|
|
|
|
|
|
|
// m_mousePosY = inBuf[i].Event.MouseEvent.dwMousePosition.Y;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// case 0:
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// for (int m = 0; m < 5; m++)
|
|
|
|
|
|
|
|
// m_mouseNewState[m] = (inBuf[i].Event.MouseEvent.dwButtonState & (1 << m)) > 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// default:
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// default:
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// // We don't care just at the moment
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*for (int m = 0; m < 5; m++)
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_mouse[m].bPressed = false; |
|
|
|
|
|
|
|
m_mouse[m].bReleased = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_mouseNewState[m] != m_mouseOldState[m]) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m_mouseNewState[m]) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_mouse[m].bPressed = true; |
|
|
|
|
|
|
|
m_mouse[m].bHeld = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_mouse[m].bReleased = true; |
|
|
|
|
|
|
|
m_mouse[m].bHeld = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_mouseOldState[m] = m_mouseNewState[m]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle Frame Update
|
|
|
|
// Handle Frame Update
|
|
|
|
if (!OnUserUpdate(fElapsedTime)) |
|
|
|
if (!OnUserUpdate(fElapsedTime)) |
|
|
|
m_bAtomActive = false; |
|
|
|
m_bAtomActive = false; |
|
|
@ -1418,6 +1356,7 @@ protected: // Audio Engine ===================================================== |
|
|
|
cvt.buf = (uint8_t *)malloc(streamLen * cvt.len_mult); |
|
|
|
cvt.buf = (uint8_t *)malloc(streamLen * cvt.len_mult); |
|
|
|
cvt.len = streamLen; |
|
|
|
cvt.len = streamLen; |
|
|
|
memcpy(cvt.buf, wavData, streamLen); |
|
|
|
memcpy(cvt.buf, wavData, streamLen); |
|
|
|
|
|
|
|
free(cvt.buf); |
|
|
|
SDL_FreeWAV((uint8_t *)wavData); |
|
|
|
SDL_FreeWAV((uint8_t *)wavData); |
|
|
|
if (SDL_ConvertAudio(&cvt) == -1) { |
|
|
|
if (SDL_ConvertAudio(&cvt) == -1) { |
|
|
|
std::cout << "Failed to convert audio!\n" << SDL_GetError() << '\n'; |
|
|
|
std::cout << "Failed to convert audio!\n" << SDL_GetError() << '\n'; |
|
|
|