parent
5979eddc21
commit
12ec38ae96
@ -0,0 +1,56 @@ |
||||
#pragma once |
||||
#include "olcPixelGameEngine.h" |
||||
#include "SMX.h" |
||||
|
||||
using namespace olc; |
||||
|
||||
|
||||
class PGEX_SMX : public PGEX{ |
||||
|
||||
public: |
||||
PGEX_SMX():PGEX(true){}; |
||||
//SMX "screen" is 12x21
|
||||
//Each panel is 4x7
|
||||
static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser) |
||||
{ |
||||
PGEX_SMX *pSelf = (PGEX_SMX*) pUser; |
||||
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)); |
||||
|
||||
} |
||||
|
||||
virtual void OnAfterUserCreate()override{ |
||||
SMX_Start( SMXStateChangedCallback, this ); |
||||
}; |
||||
|
||||
virtual void OnAfterUserUpdate(float fElapsedTime)override{ |
||||
std::string lightData; |
||||
for (int pad=0;pad<2;pad++){ |
||||
for(int i=0;i<9;i++){ |
||||
int row=0; |
||||
for(int y=i/3*7;y<i/3*7+7;y++){ |
||||
int col=0; |
||||
for(int x=i%3*4;x<i%3*4+4;x++){ |
||||
if(row%2&&col%4==0)continue; |
||||
Pixel p(pge->GetDrawTarget()->GetPixel(x,y)); |
||||
lightData.append(1,p.r); |
||||
lightData.append(1,p.g); |
||||
lightData.append(1,p.b); |
||||
col++; |
||||
} |
||||
row++; |
||||
}
|
||||
} |
||||
} |
||||
SMX_SetLights2( lightData.data(), lightData.size() ); |
||||
} |
||||
}; |
Loading…
Reference in new issue