|
|
@ -3,7 +3,7 @@ |
|
|
|
olcPixelGameEngine.h |
|
|
|
olcPixelGameEngine.h |
|
|
|
|
|
|
|
|
|
|
|
+-------------------------------------------------------------+ |
|
|
|
+-------------------------------------------------------------+ |
|
|
|
| OneLoneCoder Pixel Game Engine v2.21 | |
|
|
|
| OneLoneCoder Pixel Game Engine v2.23 | |
|
|
|
| "What do you need? Pixels... Lots of Pixels..." - javidx9 | |
|
|
|
| "What do you need? Pixels... Lots of Pixels..." - javidx9 | |
|
|
|
+-------------------------------------------------------------+ |
|
|
|
+-------------------------------------------------------------+ |
|
|
|
|
|
|
|
|
|
|
@ -197,7 +197,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
Author |
|
|
|
Author |
|
|
|
~~~~~~ |
|
|
|
~~~~~~ |
|
|
|
David Barr, aka javidx9, OneLoneCoder 2018, 2019, 2020, 2021, 2022 |
|
|
|
David Barr, aka javidx9, (c) OneLoneCoder 2018, 2019, 2020, 2021, 2022 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#pragma endregion |
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
|
@ -316,6 +316,11 @@ |
|
|
|
+FillTexturedPolygon() - Hijacks DecalStructure for configuration |
|
|
|
+FillTexturedPolygon() - Hijacks DecalStructure for configuration |
|
|
|
+olc::vf2d arguments for Sprite::Sample() functions |
|
|
|
+olc::vf2d arguments for Sprite::Sample() functions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 !! |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -394,7 +399,7 @@ int main() |
|
|
|
#include <cstring> |
|
|
|
#include <cstring> |
|
|
|
#pragma endregion |
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
|
|
#define PGE_VER 221 |
|
|
|
#define PGE_VER 223 |
|
|
|
|
|
|
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
// | COMPILER CONFIGURATION ODDITIES |
|
|
|
|
// | COMPILER CONFIGURATION ODDITIES |
|
|
|
@ -682,7 +687,7 @@ namespace olc |
|
|
|
v2d_generic min(const v2d_generic& v) const { return v2d_generic(std::min(x, v.x), std::min(y, v.y)); } |
|
|
|
v2d_generic min(const v2d_generic& v) const { return v2d_generic(std::min(x, v.x), std::min(y, v.y)); } |
|
|
|
v2d_generic cart() { return { std::cos(y) * x, std::sin(y) * x }; } |
|
|
|
v2d_generic cart() { return { std::cos(y) * x, std::sin(y) * x }; } |
|
|
|
v2d_generic polar() { return { mag(), std::atan2(y, x) }; } |
|
|
|
v2d_generic polar() { return { mag(), std::atan2(y, x) }; } |
|
|
|
v2d_generic clamp(const v2d_generic& v1, const v2d_generic& v2) const { return this->max(v1)->min(v2); } |
|
|
|
v2d_generic clamp(const v2d_generic& v1, const v2d_generic& v2) const { return this->max(v1).min(v2); } |
|
|
|
v2d_generic lerp(const v2d_generic& v1, const double t) { return this->operator*(T(1.0 - t)) + (v1 * T(t)); } |
|
|
|
v2d_generic lerp(const v2d_generic& v1, const double t) { return this->operator*(T(1.0 - t)) + (v1 * T(t)); } |
|
|
|
T dot(const v2d_generic& rhs) const { return this->x * rhs.x + this->y * rhs.y; } |
|
|
|
T dot(const v2d_generic& rhs) const { return this->x * rhs.x + this->y * rhs.y; } |
|
|
|
T cross(const v2d_generic& rhs) const { return this->x * rhs.y - this->y * rhs.x; } |
|
|
|
T cross(const v2d_generic& rhs) const { return this->x * rhs.y - this->y * rhs.x; } |
|
|
@ -971,6 +976,8 @@ namespace olc |
|
|
|
virtual bool OnUserUpdate(float fElapsedTime); |
|
|
|
virtual bool OnUserUpdate(float fElapsedTime); |
|
|
|
// Called once on application termination, so you can be one clean coder
|
|
|
|
// Called once on application termination, so you can be one clean coder
|
|
|
|
virtual bool OnUserDestroy(); |
|
|
|
virtual bool OnUserDestroy(); |
|
|
|
|
|
|
|
virtual void GetAnyKey(); |
|
|
|
|
|
|
|
virtual void GetAnyKeyPress(olc::Key pressedKey); |
|
|
|
|
|
|
|
|
|
|
|
// Called when a text entry is confirmed with "enter" key
|
|
|
|
// Called when a text entry is confirmed with "enter" key
|
|
|
|
virtual void OnTextEntryComplete(const std::string& sText); |
|
|
|
virtual void OnTextEntryComplete(const std::string& sText); |
|
|
@ -1357,8 +1364,9 @@ namespace olc |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if defined(OLC_PLATFORM_X11) |
|
|
|
#if defined(OLC_PLATFORM_X11) |
|
|
|
namespace X11 |
|
|
|
namespace X11 { |
|
|
|
{#include <GL/glx.h>} |
|
|
|
#include <GL/glx.h> |
|
|
|
|
|
|
|
} |
|
|
|
#define CALLSTYLE |
|
|
|
#define CALLSTYLE |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -3674,6 +3682,9 @@ namespace olc |
|
|
|
bool PixelGameEngine::OnUserDestroy() |
|
|
|
bool PixelGameEngine::OnUserDestroy() |
|
|
|
{ return true; } |
|
|
|
{ return true; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::GetAnyKey(){}; |
|
|
|
|
|
|
|
void PixelGameEngine::GetAnyKeyPress(olc::Key pressedKey){}; |
|
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); } |
|
|
|
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); } |
|
|
|
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; } |
|
|
|
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; } |
|
|
|
|
|
|
|
|
|
|
@ -3831,8 +3842,10 @@ namespace olc |
|
|
|
platform->HandleSystemEvent(); |
|
|
|
platform->HandleSystemEvent(); |
|
|
|
|
|
|
|
|
|
|
|
// Compare hardware input states from previous frame
|
|
|
|
// Compare hardware input states from previous frame
|
|
|
|
auto ScanHardware = [&](HWButton* pKeys, bool* pStateOld, bool* pStateNew, uint32_t nKeyCount) |
|
|
|
auto ScanHardware = [&](HWButton* pKeys, bool* pStateOld, bool* pStateNew, uint32_t nKeyCount,bool keyboard=true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
bool pressed=false; |
|
|
|
|
|
|
|
int key; |
|
|
|
for (uint32_t i = 0; i < nKeyCount; i++) |
|
|
|
for (uint32_t i = 0; i < nKeyCount; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pKeys[i].bPressed = false; |
|
|
|
pKeys[i].bPressed = false; |
|
|
@ -3841,6 +3854,8 @@ namespace olc |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pStateNew[i]) |
|
|
|
if (pStateNew[i]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
pressed=true; |
|
|
|
|
|
|
|
key=i; |
|
|
|
pKeys[i].bPressed = !pKeys[i].bHeld; |
|
|
|
pKeys[i].bPressed = !pKeys[i].bHeld; |
|
|
|
pKeys[i].bHeld = true; |
|
|
|
pKeys[i].bHeld = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -3849,13 +3864,18 @@ namespace olc |
|
|
|
pKeys[i].bReleased = true; |
|
|
|
pKeys[i].bReleased = true; |
|
|
|
pKeys[i].bHeld = false; |
|
|
|
pKeys[i].bHeld = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
GetAnyKey(); |
|
|
|
} |
|
|
|
} |
|
|
|
pStateOld[i] = pStateNew[i]; |
|
|
|
pStateOld[i] = pStateNew[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (pressed) { |
|
|
|
|
|
|
|
if (keyboard) {GetAnyKeyPress((olc::Key)key);} |
|
|
|
|
|
|
|
else {GetAnyKeyPress(olc::Key::NONE);} |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256); |
|
|
|
ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256); |
|
|
|
ScanHardware(pMouseState, pMouseOldState, pMouseNewState, nMouseButtons); |
|
|
|
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; |
|
|
@ -4594,17 +4614,17 @@ namespace olc |
|
|
|
// #include <OpenGL/glu.h>
|
|
|
|
// #include <OpenGL/glu.h>
|
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
//#if defined(OLC_PLATFORM_EMSCRIPTEN)
|
|
|
|
#if defined(OLC_PLATFORM_EMSCRIPTEN) |
|
|
|
// #include <EGL/egl.h>
|
|
|
|
#include <EGL/egl.h> |
|
|
|
// #include <GLES2/gl2.h>
|
|
|
|
#include <GLES2/gl2.h> |
|
|
|
// #define GL_GLEXT_PROTOTYPES
|
|
|
|
#define GL_GLEXT_PROTOTYPES |
|
|
|
// #include <GLES2/gl2ext.h>
|
|
|
|
#include <GLES2/gl2ext.h> |
|
|
|
// #include <emscripten/emscripten.h>
|
|
|
|
#include <emscripten/emscripten.h> |
|
|
|
// #define CALLSTYLE
|
|
|
|
#define CALLSTYLE |
|
|
|
// typedef EGLBoolean(locSwapInterval_t)(EGLDisplay display, EGLint interval);
|
|
|
|
typedef EGLBoolean(locSwapInterval_t)(EGLDisplay display, EGLint interval); |
|
|
|
// #define GL_CLAMP GL_CLAMP_TO_EDGE
|
|
|
|
#define GL_CLAMP GL_CLAMP_TO_EDGE |
|
|
|
// #define OGL_LOAD(t, n) n;
|
|
|
|
#define OGL_LOAD(t, n) n; |
|
|
|
//#endif
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
namespace olc |
|
|
|
namespace olc |
|
|
|
{ |
|
|
|
{ |
|
|
@ -5574,7 +5594,7 @@ namespace olc |
|
|
|
vFiles.push_back(std::string(buffer)); |
|
|
|
vFiles.push_back(std::string(buffer)); |
|
|
|
delete[] buffer; |
|
|
|
delete[] buffer; |
|
|
|
#else |
|
|
|
#else |
|
|
|
vFiles.push_back(std::string(dbuffer)); |
|
|
|
vFiles.push_back(std::string(dfbuffer)); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -6318,8 +6338,8 @@ namespace olc |
|
|
|
let isFullscreen = (document.fullscreenElement != null); |
|
|
|
let isFullscreen = (document.fullscreenElement != null); |
|
|
|
|
|
|
|
|
|
|
|
// get the width of the containing element
|
|
|
|
// get the width of the containing element
|
|
|
|
let width = (isFullscreen || !Module.olc_AssumeDefaultShells) ? window.innerWidth : Module.canvas.parentNode.clientWidth; |
|
|
|
let width = (isFullscreen) ? window.innerWidth : Module.canvas.parentNode.clientWidth; |
|
|
|
let height = (isFullscreen || !Module.olc_AssumeDefaultShells) ? window.innerHeight : Module.canvas.parentNode.clientHeight; |
|
|
|
let height = (isFullscreen) ? window.innerHeight : Module.canvas.parentNode.clientHeight; |
|
|
|
|
|
|
|
|
|
|
|
// calculate the expected viewport size
|
|
|
|
// calculate the expected viewport size
|
|
|
|
let viewWidth = width; |
|
|
|
let viewWidth = width; |
|
|
|