SMX_PGE/sample/SMXSample.cpp

58 lines
1.2 KiB
C++
Raw Normal View History

2017-12-14 20:02:36 -06:00
#include "SMX.h"
2023-06-16 18:51:30 -05:00
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
using namespace olc;
2017-12-14 20:02:36 -06:00
2023-06-16 18:51:30 -05:00
class SMX_PGE : public olc::PixelGameEngine
2017-12-14 20:02:36 -06:00
{
public:
2023-06-16 18:51:30 -05:00
SMX_PGE()
2017-12-14 20:02:36 -06:00
{
2023-06-16 18:51:30 -05:00
sAppName = "Example";
2017-12-14 20:02:36 -06:00
}
static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser)
{
2023-06-16 18:51:30 -05:00
SMX_PGE *pSelf = (SMX_PGE*) pUser;
2017-12-14 20:02:36 -06:00
pSelf->SMXStateChanged( pad, reason );
}
static void SMXLogCallback(const char *log)
{
printf("-> %s\n", log);
}
void SMXStateChanged(int pad, SMXUpdateCallbackReason reason)
{
printf("Device %i state changed: %04x\n", pad, SMX_GetInputState(pad));
}
2023-06-16 18:51:30 -05:00
public:
bool OnUserCreate() override
2017-12-14 20:02:36 -06:00
{
2023-06-16 18:51:30 -05:00
SMX_Start( SMXStateChangedCallback, this );
// Called once at the start, so create things here
return true;
}
2017-12-14 20:02:36 -06:00
2023-06-16 18:51:30 -05:00
bool OnUserUpdate(float fElapsedTime) override
{
// called once per frame
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));
return true;
2017-12-14 20:02:36 -06:00
}
};
2023-06-16 18:51:30 -05:00
2017-12-14 20:02:36 -06:00
int main()
{
2023-06-16 18:51:30 -05:00
SMX_PGE demo;
if (demo.Construct(256, 240, 4, 4))
demo.Start();
2017-12-14 20:02:36 -06:00
return 0;
}