Add in demo
This commit is contained in:
parent
b063523474
commit
e473e5ee21
@ -6,6 +6,9 @@ using namespace olc;
|
|||||||
class SMX_PGE : public olc::PixelGameEngine
|
class SMX_PGE : public olc::PixelGameEngine
|
||||||
{
|
{
|
||||||
PGEX_SMX smx;
|
PGEX_SMX smx;
|
||||||
|
bool paused = false;
|
||||||
|
int mode = 0;
|
||||||
|
vf2d playerPos = { 0,0 };
|
||||||
public:
|
public:
|
||||||
SMX_PGE()
|
SMX_PGE()
|
||||||
{
|
{
|
||||||
@ -25,10 +28,43 @@ public:
|
|||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
{
|
{
|
||||||
|
if (GetKey(RIGHT).bPressed) {
|
||||||
|
mode = (mode + 1) % 3;
|
||||||
|
}
|
||||||
|
switch (mode) {
|
||||||
|
case 0: {
|
||||||
|
if (GetKey(SPACE).bPressed) {
|
||||||
|
paused = !paused;
|
||||||
|
}
|
||||||
// called once per frame
|
// called once per frame
|
||||||
|
if (!paused) {
|
||||||
for (int x = 0; x < ScreenWidth(); x++)
|
for (int x = 0; x < ScreenWidth(); x++)
|
||||||
for (int y = 0; y < ScreenHeight(); y++)
|
for (int y = 0; y < ScreenHeight(); y++)
|
||||||
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand() % 255));
|
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand() % 255));
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case 1: {
|
||||||
|
Clear(DARK_CYAN);
|
||||||
|
DrawRect({ 1,1 }, { 9,18 }, RED);
|
||||||
|
}break;
|
||||||
|
case 2: {
|
||||||
|
Clear(VERY_DARK_BLUE);
|
||||||
|
FillCircle(playerPos, 3,VERY_DARK_GREY);
|
||||||
|
DrawCircle(playerPos, 3);
|
||||||
|
if (GetKey(W).bHeld) {
|
||||||
|
playerPos.y -= 5*fElapsedTime;
|
||||||
|
}
|
||||||
|
if (GetKey(A).bHeld) {
|
||||||
|
playerPos.x -= 5 * fElapsedTime;
|
||||||
|
}
|
||||||
|
if (GetKey(S).bHeld) {
|
||||||
|
playerPos.y += 5 * fElapsedTime;
|
||||||
|
}
|
||||||
|
if (GetKey(D).bHeld) {
|
||||||
|
playerPos.x += 5 * fElapsedTime;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user