Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ olcPixelGameEngine is used by 100s, if not 1000s of programmers at all levels of
Please see https://github.com/OneLoneCoder/olcPixelGameEngine/wiki

# License (OLC-3)

Copyright 2018, 2019, 2020, 2021, 2022, 2023 OneLoneCoder.com
Copyright 2018 - 2024 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down
13 changes: 10 additions & 3 deletions extensions/olcPGEX_QuickGUI.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
OneLoneCoder - QuickGUI v1.02
OneLoneCoder - QuickGUI v1.03
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A semi-immediate mode GUI for very simple GUI stuff.
Includes:
Expand All @@ -15,7 +15,7 @@
License (OLC-3)
~~~~~~~~~~~~~~~

Copyright 2018 - 2021 OneLoneCoder.com
Copyright 2018 - 2024 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -56,7 +56,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022, 2023, 2024

Changes
~~~~~~~
Expand All @@ -68,6 +68,7 @@
+ListBox::bSelectionChanged flag, true when list selected item changes
=Fix - Text box mouse behaviours, mouse release is now meaningless
+CheckBox Fix for decal display
v1.03 =Fix ImageCheckBox

*/

Expand Down Expand Up @@ -807,6 +808,12 @@ namespace olc::QuickGUI
return;

ImageButton::DrawDecal(pge);

if (bChecked)
{
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colClick);
pge->DrawDecal(vPos + olc::vi2d(4, 4), pIcon.Decal());
}

pge->SetDecalMode(olc::DecalMode::WIREFRAME);
pge->FillRectDecal(vPos + olc::vf2d(2, 2), vSize - olc::vf2d(4, 4), m_manager.colBorder);
Expand Down
8 changes: 4 additions & 4 deletions extensions/olcPGEX_SplashScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
License (OLC-3)
~~~~~~~~~~~~~~~

Copyright 2018 - 2022 OneLoneCoder.com
Copyright 2018 - 2024 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -58,7 +58,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022, 2023, 2024

Revisions:
1.00: Initial Release
Expand Down Expand Up @@ -210,8 +210,8 @@ namespace olc
pge->DrawPartialDecal(vScale * vBoom[y * spr.Sprite()->width + x].first * 2.0f, spr.Decal(), olc::vf2d(x, y), { 1, 1 }, vScale * 2.0f, olc::PixelF(1.0f, 1.0f, 1.0f, std::min(1.0f, std::max(4.0f - fParticleTime, 0.0f))));
}

olc::vi2d vSize = pge->GetTextSizeProp("Copyright OneLoneCoder.com 2022");
pge->DrawStringPropDecal(olc::vf2d(float(pge->ScreenWidth()/2) - vSize.x/2, float(pge->ScreenHeight()) - vSize.y * 3.0f), "Copyright OneLoneCoder.com 2022", olc::PixelF(1.0f, 1.0f, 1.0f, 0.5f), olc::vf2d(1.0, 2.0f));
olc::vi2d vSize = pge->GetTextSizeProp("Copyright OneLoneCoder.com 2024");
pge->DrawStringPropDecal(olc::vf2d(float(pge->ScreenWidth()/2) - vSize.x/2, float(pge->ScreenHeight()) - vSize.y * 3.0f), "Copyright OneLoneCoder.com 2023", olc::PixelF(1.0f, 1.0f, 1.0f, 0.5f), olc::vf2d(1.0, 2.0f));
return true;
}

Expand Down
30 changes: 27 additions & 3 deletions extensions/olcPGEX_TransformedView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

+-------------------------------------------------------------+
| OneLoneCoder Pixel Game Engine Extension |
| Transformed View v1.08 |
| Transformed View v1.09 |
+-------------------------------------------------------------+

NOTE: UNDER ACTIVE DEVELOPMENT - THERE ARE BUGS/GLITCHES
Expand All @@ -18,7 +18,7 @@
License (OLC-3)
~~~~~~~~~~~~~~~

Copyright 2018 - 2022 OneLoneCoder.com
Copyright 2018 - 2024 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -59,7 +59,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022, 2023, 2024

Revisions:
1.00: Initial Release
Expand All @@ -74,6 +74,10 @@
1.07: +DrawRectDecal()
+GetPGE()
1.08: +DrawPolygonDecal() with tint overload, akin to PGE
1.09: +SetScaleExtents() - Sets range that world scale can exist within
+EnableScaleClamp() - Applies a range that scaling is clamped to
These are both useful for having zoom clamped between a min and max
without weird panning artefacts occuring
*/

#pragma once
Expand Down Expand Up @@ -116,6 +120,9 @@ namespace olc
virtual bool IsPointVisible(const olc::vf2d& vPos) const;
virtual bool IsRectVisible(const olc::vf2d& vPos, const olc::vf2d& vSize) const;
virtual void HandlePanAndZoom(const int nMouseButton = 2, const float fZoomRate = 0.1f, const bool bPan = true, const bool bZoom = true);
void SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax);
void EnableScaleClamp(const bool bEnable);

protected:
olc::vf2d m_vWorldOffset = { 0.0f, 0.0f };
olc::vf2d m_vWorldScale = { 1.0f, 1.0f };
Expand All @@ -124,6 +131,9 @@ namespace olc
bool m_bPanning = false;
olc::vf2d m_vStartPan = { 0.0f, 0.0f };
olc::vi2d m_vViewArea;
bool m_bZoomClamp = false;
olc::vf2d m_vMaxScale = { 0.0f, 0.0f };
olc::vf2d m_vMinScale = { 0.0f, 0.0f };

public: // Hopefully, these should look familiar!
// Plots a single point
Expand Down Expand Up @@ -253,6 +263,7 @@ namespace olc
void TransformedView::SetWorldScale(const olc::vf2d& vScale)
{
m_vWorldScale = vScale;
if (m_bZoomClamp) m_vWorldScale = m_vWorldScale.clamp(m_vMinScale, m_vMaxScale);
}

void TransformedView::SetViewArea(const olc::vi2d& vViewArea)
Expand All @@ -275,10 +286,22 @@ namespace olc
return GetWorldBR() - GetWorldTL();
}

void TransformedView::SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax)
{
m_vMaxScale = vScaleMax;
m_vMinScale = vScaleMin;
}

void TransformedView::EnableScaleClamp(const bool bEnable)
{
m_bZoomClamp = bEnable;
}

void TransformedView::ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos)
{
olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
m_vWorldScale *= fDeltaZoom;
if (m_bZoomClamp) m_vWorldScale = m_vWorldScale.clamp(m_vMinScale, m_vMaxScale);
olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
}
Expand All @@ -287,6 +310,7 @@ namespace olc
{
olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
m_vWorldScale = { fZoom, fZoom };
if (m_bZoomClamp) m_vWorldScale = m_vWorldScale.clamp(m_vMinScale, m_vMaxScale);
olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
}
Expand Down
19 changes: 10 additions & 9 deletions olcPixelGameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
olcPixelGameEngine.h

+-------------------------------------------------------------+
| OneLoneCoder Pixel Game Engine v2.23 |
| OneLoneCoder Pixel Game Engine v2.24 |
| "What do you need? Pixels... Lots of Pixels..." - javidx9 |
+-------------------------------------------------------------+

Expand Down Expand Up @@ -193,11 +193,11 @@
Special thanks to my Patreons too - I wont name you on here, but I've
certainly enjoyed my tea and flapjacks :D


- In Memory of SaladinAkara 25.06.2023 -

Author
~~~~~~
David Barr, aka javidx9, (c) OneLoneCoder 2018, 2019, 2020, 2021, 2022
David Barr, aka javidx9, (c) OneLoneCoder 2018, 2019, 2020, 2021, 2022, 2023, 2024
*/
#pragma endregion

Expand Down Expand Up @@ -318,6 +318,7 @@
2.22: = Fix typo on dragged file buffers for unicode builds
2.23: Fixed Emscripten host sizing errors - Thanks Moros
Fixed v2d_generic.clamp() function
2.24: Fix FillTexturedTriangle() to remove const-ref

!! 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 !!
Expand Down Expand Up @@ -397,7 +398,7 @@ int main()
#include <cstring>
#pragma endregion

#define PGE_VER 223
#define PGE_VER 224

// O------------------------------------------------------------------------------O
// | COMPILER CONFIGURATION ODDITIES |
Expand Down Expand Up @@ -1086,7 +1087,7 @@ namespace olc
void FillTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p = olc::WHITE);
void FillTriangle(const olc::vi2d& pos1, const olc::vi2d& pos2, const olc::vi2d& pos3, Pixel p = olc::WHITE);
// Fill a textured and coloured triangle
void FillTexturedTriangle(const std::vector<olc::vf2d>& vPoints, std::vector<olc::vf2d> vTex, std::vector<olc::Pixel> vColour, olc::Sprite* sprTex);
void FillTexturedTriangle(std::vector<olc::vf2d> vPoints, std::vector<olc::vf2d> vTex, std::vector<olc::Pixel> vColour, olc::Sprite* sprTex);
void FillTexturedPolygon(const std::vector<olc::vf2d>& vPoints, const std::vector<olc::vf2d>& vTex, const std::vector<olc::Pixel>& vColour, olc::Sprite* sprTex, olc::DecalStructure structure = olc::DecalStructure::LIST);
// Draws an entire sprite at location (x,y)
void DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE);
Expand Down Expand Up @@ -2187,8 +2188,8 @@ namespace olc
auto rol = [&](void) { pattern = (pattern << 1) | (pattern >> 31); return pattern & 1; };

olc::vi2d p1(x1, y1), p2(x2, y2);
//if (!ClipLineToScreen(p1, p2))
// return;
if (!ClipLineToScreen(p1, p2))
return;
x1 = p1.x; y1 = p1.y;
x2 = p2.x; y2 = p2.y;

Expand Down Expand Up @@ -2580,7 +2581,7 @@ namespace olc
}
}

void PixelGameEngine::FillTexturedTriangle(const std::vector<olc::vf2d>& vPoints, std::vector<olc::vf2d> vTex, std::vector<olc::Pixel> vColour, olc::Sprite* sprTex)
void PixelGameEngine::FillTexturedTriangle(std::vector<olc::vf2d> vPoints, std::vector<olc::vf2d> vTex, std::vector<olc::Pixel> vColour, olc::Sprite* sprTex)
{
olc::vi2d p1 = vPoints[0];
olc::vi2d p2 = vPoints[1];
Expand Down Expand Up @@ -2996,7 +2997,7 @@ namespace olc
di.pos[i] = { (pos[i].x * vInvScreenSize.x) * 2.0f - 1.0f, ((pos[i].y * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f };
di.uv[i] = uv[i];
di.tint[i] = tint;
di.w[i] = 1.0f;
di.w[i] = depth[i];
}
di.mode = nDecalMode;
di.structure = nDecalStructure;
Expand Down
17 changes: 13 additions & 4 deletions utilities/olcUTIL_Animate2D.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
OneLoneCoder - Animate2D v1.00
OneLoneCoder - Animate2D v1.01
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Handles animated Sprites efficiently


License (OLC-3)
~~~~~~~~~~~~~~~

Copyright 2018 - 2022 OneLoneCoder.com
Copyright 2018 - 2024 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -48,14 +48,19 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022
David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022, 2023, 2024


Versions
~~~~~~~~
1.01 +PingPong Style Animation
*/

#pragma once

#include "olcPixelGameEngine.h"
#include "utilities/olcUTIL_Geometry2D.h"
#include <unordered_map>

namespace olc::utils::Animate2D
{
Expand Down Expand Up @@ -141,7 +146,11 @@ namespace olc::utils::Animate2D
return std::clamp(size_t(fTime * m_fFrameRate), size_t(0), m_vFrames.size() - 1);
break;
case Style::PingPong:
// TODO
{
// Thanks @sigonasr2 (discord)
size_t frame = size_t(m_fFrameRate * fTime) % (m_vFrames.size() * 2 - 1);
return frame >= m_vFrames.size() ? m_vFrames.size() - frame % m_vFrames.size() - 1 : frame;
}
break;
case Style::Reverse:
return (m_vFrames.size() - 1) - (size_t(fTime * m_fFrameRate) % m_vFrames.size());
Expand Down
Loading