Updated Graphics 2D

This commit is contained in:
Javidx9
2019-02-03 14:33:47 +00:00
committed by GitHub
parent b854c55cb7
commit 9d1b6952be
2 changed files with 41 additions and 11 deletions

View File

@@ -46,7 +46,7 @@
Author
~~~~~~
David Barr, aka javidx9, ©OneLoneCoder 2018
David Barr, aka javidx9, ©OneLoneCoder 2018
*/
// Include the olcPixelGameEngine
@@ -54,6 +54,7 @@
#include "olcPixelGameEngine.h"
// To use an extension, just include it
#define OLC_PGE_GRAPHICS2D
#include "olcPGEX_Graphics2D.h"
class TestExtension : public olc::PixelGameEngine
@@ -70,7 +71,7 @@ public:
for (int i = 0; i < 16; i++)
listEvents.push_back("");
spr = new olc::Sprite("logo_long.png");
spr = new olc::Sprite("new_piskel.png");
return true;
}
@@ -90,8 +91,8 @@ public:
DrawCircle(96, 32, 30); // Circle
float mx = GetMouseX();
float my = GetMouseY();
float mx = (float)GetMouseX();
float my = (float)GetMouseY();
float px1 = mx - 32, px2 = mx - 96;
float py1 = my - 32, py2 = my - 32;
@@ -101,8 +102,8 @@ public:
py1 = 22.0f * (py1 * pr1) + 32.0f;
px2 = 22.0f * (px2 * pr2) + 96.0f;
py2 = 22.0f * (py2 * pr2) + 32.0f;
FillCircle(px1, py1, 8, olc::CYAN);
FillCircle(px2, py2, 8, olc::CYAN);
FillCircle((int32_t)px1, (int32_t)py1, 8, olc::CYAN);
FillCircle((int32_t)px2, (int32_t)py2, 8, olc::CYAN);
DrawLine(10, 70, 54, 70); // Lines
DrawLine(54, 70, 70, 54);
@@ -136,6 +137,8 @@ public:
nLog++;
}
std::string notes = "CDEFGAB";
// Test Text scaling and colours
DrawString(0, 360, "Text Scale = 1", olc::WHITE, 1);
@@ -168,6 +171,8 @@ public:
// Use extension to draw sprite with transform applied
olc::GFX2D::DrawSprite(spr, t1);
DrawSprite((int32_t)mx, (int32_t)my, spr, 4);
return true;
}
@@ -181,4 +186,4 @@ int main()
demo.Start();
return 0;
}
}