Added 0.6 PGE
This commit is contained in:
parent
26997cc02d
commit
bb9cfe227a
@ -2,7 +2,7 @@
|
||||
olcPixelGameEngine.h
|
||||
|
||||
+-------------------------------------------------------------+
|
||||
| OneLoneCoder Pixel Game Engine v0.5 |
|
||||
| OneLoneCoder Pixel Game Engine v0.6 |
|
||||
| "Like the command prompt console one, but not..." - javidx9 |
|
||||
+-------------------------------------------------------------+
|
||||
|
||||
@ -292,7 +292,7 @@ namespace olc // All OneLoneCoder stuff will now exist in the "olc" namespace
|
||||
// Get the state of a specific keyboard button
|
||||
HWButton GetKey(Key k);
|
||||
// Get the state of a specific mouse button
|
||||
HWButton GetMouse(char b);
|
||||
HWButton GetMouse(uint32_t b);
|
||||
// Get Mouse X coordinate in "pixel" space
|
||||
int32_t GetMouseX();
|
||||
// Get Mouse Y coordinate in "pixel" space
|
||||
@ -626,9 +626,11 @@ namespace olc
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef UNICODE
|
||||
#ifndef __MINGW32__
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
wsAppName = converter.from_bytes(sAppName);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
// Load the default font sheet
|
||||
olc_ConstructFontSheet();
|
||||
@ -713,7 +715,7 @@ namespace olc
|
||||
return pKeyboardState[k];
|
||||
}
|
||||
|
||||
HWButton PixelGameEngine::GetMouse(char b)
|
||||
HWButton PixelGameEngine::GetMouse(uint32_t b)
|
||||
{
|
||||
return pMouseState[b];
|
||||
}
|
||||
@ -750,7 +752,7 @@ namespace olc
|
||||
|
||||
if (nPixelMode == Pixel::MASK)
|
||||
{
|
||||
if(p.a != 255)
|
||||
if(p.a == 255)
|
||||
pDrawTarget->SetPixel(x, y, p);
|
||||
return;
|
||||
}
|
||||
@ -1079,15 +1081,26 @@ namespace olc
|
||||
|
||||
void PixelGameEngine::DrawString(int32_t x, int32_t y, std::string sText)
|
||||
{
|
||||
int32_t s = 0;
|
||||
int32_t sx = 0;
|
||||
int32_t sy = 0;
|
||||
Pixel::Mode m = nPixelMode;
|
||||
SetPixelMode(Pixel::MASK);
|
||||
for (auto c : sText)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
sx = 0; sy += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t ox = (c - 32) % 16;
|
||||
int32_t oy = (c - 32) / 16;
|
||||
DrawPartialSprite(x + s, y, fontSprite, ox*8, oy*8, 8, 8);
|
||||
s+=8;
|
||||
DrawPartialSprite(x + sx, y + sy, fontSprite, ox * 8, oy * 8, 8, 8);
|
||||
sx += 8;
|
||||
}
|
||||
}
|
||||
SetPixelMode(m);
|
||||
}
|
||||
|
||||
void PixelGameEngine::SetPixelMode(Pixel::Mode m)
|
||||
{
|
||||
@ -1172,11 +1185,11 @@ namespace olc
|
||||
}
|
||||
else if (xev.type == ButtonPress)
|
||||
{
|
||||
pMouseNewState[xev.xbutton.button] = true;
|
||||
pMouseNewState[xev.xbutton.button-1] = true;
|
||||
}
|
||||
else if (xev.type == ButtonRelease)
|
||||
{
|
||||
pMouseNewState[xev.xbutton.button] = false;
|
||||
pMouseNewState[xev.xbutton.button-1] = false;
|
||||
}
|
||||
else if (xev.type == MotionNotify)
|
||||
{
|
||||
@ -1357,7 +1370,7 @@ namespace olc
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
int k = r & (1 << i) ? 255 : 0;
|
||||
fontSprite->SetPixel(px, py, olc::Pixel(k, k, k));
|
||||
fontSprite->SetPixel(px, py, olc::Pixel(k, k, k, k));
|
||||
if (++py == 48) { px++; py = 0; }
|
||||
}
|
||||
}
|
||||
@ -1397,10 +1410,10 @@ namespace olc
|
||||
|
||||
#ifdef UNICODE
|
||||
olc_hWnd = CreateWindowEx(dwExStyle, L"OLC_PIXEL_GAME_ENGINE", L"", dwStyle,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, GetModuleHandle(nullptr), this);
|
||||
30, 30, width, height, NULL, NULL, GetModuleHandle(nullptr), this);
|
||||
#else
|
||||
olc_hWnd = CreateWindowEx(dwExStyle, "OLC_PIXEL_GAME_ENGINE", "", dwStyle,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, GetModuleHandle(nullptr), this);
|
||||
30, 30, width, height, NULL, NULL, GetModuleHandle(nullptr), this);
|
||||
#endif
|
||||
|
||||
// Create Keyboard Mapping
|
||||
@ -1497,7 +1510,7 @@ namespace olc
|
||||
olc_SetWindowAttribs.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
|
||||
|
||||
// Create the window
|
||||
olc_Window = XCreateWindow(olc_Display, olc_WindowRoot, 0, 0, nScreenWidth * nPixelWidth, nScreenHeight * nPixelHeight, 0, olc_VisualInfo->depth, InputOutput, olc_VisualInfo->visual, CWColormap | CWEventMask, &olc_SetWindowAttribs);
|
||||
olc_Window = XCreateWindow(olc_Display, olc_WindowRoot, 30, 30, nScreenWidth * nPixelWidth, nScreenHeight * nPixelHeight, 0, olc_VisualInfo->depth, InputOutput, olc_VisualInfo->visual, CWColormap | CWEventMask, &olc_SetWindowAttribs);
|
||||
|
||||
Atom wmDelete = XInternAtom(olc_Display, "WM_DELETE_WINDOW", true);
|
||||
XSetWMProtocols(olc_Display, olc_Window, &wmDelete, 1);
|
||||
@ -1535,12 +1548,22 @@ namespace olc
|
||||
{
|
||||
glDeviceContext = glXCreateContext(olc_Display, olc_VisualInfo, nullptr, GL_TRUE);
|
||||
glXMakeCurrent(olc_Display, olc_Window, glDeviceContext);
|
||||
|
||||
XWindowAttributes gwa;
|
||||
XGetWindowAttributes(olc_Display, olc_Window, &gwa);
|
||||
glViewport(0, 0, gwa.width, gwa.height);
|
||||
|
||||
glSwapIntervalEXT = nullptr;
|
||||
glSwapIntervalEXT = (glSwapInterval_t*)glXGetProcAddress((unsigned char*)"glXSwapIntervalEXT");
|
||||
if (glSwapIntervalEXT)
|
||||
glSwapIntervalEXT(olc_Display, olc_Window, 0);
|
||||
else
|
||||
{
|
||||
printf("NOTE: Could not disable VSYNC, glXSwapIntervalEXT() was not found!\n");
|
||||
printf(" Don't worry though, things will still work, it's just the\n");
|
||||
printf(" frame rate will be capped to your monitors refresh rate - javidx9\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1552,3 +1575,6 @@ namespace olc
|
||||
std::map<uint16_t, uint8_t> PixelGameEngine::mapKeys;
|
||||
//=============================================================
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user