You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.9 KiB
78 lines
1.9 KiB
1 year ago
|
#define OLC_PGE_APPLICATION
|
||
|
#include "olcPixelGameEngine.h"
|
||
1 year ago
|
#include "PGEX_SMX.h"
|
||
1 year ago
|
using namespace olc;
|
||
7 years ago
|
|
||
1 year ago
|
class SMX_PGE : public olc::PixelGameEngine
|
||
7 years ago
|
{
|
||
1 year ago
|
PGEX_SMX smx;
|
||
1 year ago
|
bool paused = false;
|
||
|
int mode = 0;
|
||
|
vf2d playerPos = { 0,0 };
|
||
7 years ago
|
public:
|
||
1 year ago
|
SMX_PGE()
|
||
7 years ago
|
{
|
||
1 year ago
|
sAppName = "SMX PGE";
|
||
7 years ago
|
}
|
||
|
|
||
1 year ago
|
public:
|
||
|
bool OnUserCreate() override
|
||
7 years ago
|
{
|
||
1 year ago
|
// Called once at the start, so create things here
|
||
|
return true;
|
||
|
}
|
||
7 years ago
|
|
||
1 year ago
|
bool OnUserUpdate(float fElapsedTime) override
|
||
|
{
|
||
1 year ago
|
smx.GetPanel(RIGHT, 0).bHeld;
|
||
1 year ago
|
if (GetKey(RIGHT).bPressed) {
|
||
|
mode = (mode + 1) % 3;
|
||
|
}
|
||
|
switch (mode) {
|
||
|
case 0: {
|
||
|
if (GetKey(SPACE).bPressed) {
|
||
|
paused = !paused;
|
||
|
}
|
||
|
// called once per frame
|
||
|
if (!paused) {
|
||
|
for (int x = 0; x < ScreenWidth(); x++)
|
||
|
for (int y = 0; y < ScreenHeight(); y++)
|
||
|
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;
|
||
|
}
|
||
1 year ago
|
return true;
|
||
7 years ago
|
}
|
||
|
};
|
||
|
|
||
1 year ago
|
|
||
7 years ago
|
int main()
|
||
|
{
|
||
1 year ago
|
SMX_PGE demo;
|
||
1 year ago
|
if (demo.Construct(12, 21, 50, 50))
|
||
1 year ago
|
demo.Start();
|
||
7 years ago
|
|
||
|
return 0;
|
||
|
}
|