|
|
|
#define OLC_PGE_APPLICATION
|
|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
#include "PGEX_SMX.h"
|
|
|
|
#include "util.h"
|
|
|
|
using namespace olc;
|
|
|
|
|
|
|
|
class SMX_PGE : public olc::PixelGameEngine
|
|
|
|
{
|
|
|
|
PGEX_SMX smx;
|
|
|
|
bool paused = false;
|
|
|
|
int mode = 0;
|
|
|
|
vf2d playerPos = { 0,0 };
|
|
|
|
public:
|
|
|
|
SMX_PGE()
|
|
|
|
{
|
|
|
|
sAppName = "SMX PGE";
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool OnUserCreate() override
|
|
|
|
{
|
|
|
|
// Called once at the start, so create things here
|
|
|
|
//smx.EnableLogMessages(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Pad{
|
|
|
|
int consecutiveNotesHit{0}; //Once more than 100 are hit in a row, we're online.
|
|
|
|
float lastNoteHit{0.f}; //Amount of time that passed since the last note was hit. If this goes above ten seconds, reset consectiveNotesHit.
|
|
|
|
float idleTime{0.f}; //Timer that determines if the pad has been in an idle state long enough to issue a warning.
|
|
|
|
bool alertActive{false}; //Turns on when the alert sound should be played. Sets back to false when idle time is reset.
|
|
|
|
}
|
|
|
|
|
|
|
|
Pad p1,p2;
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override
|
|
|
|
{
|
|
|
|
Clear({0,0,0});
|
|
|
|
|
|
|
|
SetPixelMode(Pixel::ALPHA);
|
|
|
|
p1.lastNoteHit+=fElapsedTime;
|
|
|
|
p2.lastNoteHit+=fElapsedTime;
|
|
|
|
p1.idleTime+=fElapsedTime;
|
|
|
|
p2.idleTime+=fElapsedTime;
|
|
|
|
FillRect({0,0},{12,21},{32,0,32,64});
|
|
|
|
FillRect({12,0},{12,21},{0,32,32,64});
|
|
|
|
|
|
|
|
if(p1.idleTime>=120.f){
|
|
|
|
//Over the next 40 seconds, the outline of the pad will slowly enclose in.
|
|
|
|
const float timeRatio{(160.f-p1.idleTime)/40.f};
|
|
|
|
DrawRect({0,0},{int(12),int(11*timeRatio)},{255,0,0,uint8_t(timeRatio*255)}) //Top
|
|
|
|
DrawRect({0,int(21-11*timeRatio)},{int(12),int(11*timeRatio)},{255,0,0,uint8_t(timeRatio*255)}) //Bottom
|
|
|
|
DrawRect({0,0},{int(6*timeRatio),int(21)},{255,0,0,uint8_t(timeRatio*255)}) //Left
|
|
|
|
DrawRect({int(12-6*timeRatio),0},{int(6*timeRatio),int(21)},{255,0,0,uint8_t(timeRatio*255)}) //Right
|
|
|
|
}
|
|
|
|
if(p2.idleTime>=120.f){
|
|
|
|
//Over the next 40 seconds, the outline of the pad will slowly enclose in.
|
|
|
|
const float timeRatio{(160.f-p2.idleTime)/40.f};
|
|
|
|
DrawRect({12,0},{int(12),int(11*timeRatio)},{255,0,0,uint8_t(timeRatio*255)}) //Top
|
|
|
|
DrawRect({12,int(21-11*timeRatio)},{int(12),int(11*timeRatio)},{255,0,0,uint8_t(timeRatio*255)}) //Bottom
|
|
|
|
DrawRect({12,0},{int(6*timeRatio),int(21)},{255,0,0,uint8_t(timeRatio*255)}) //Left
|
|
|
|
DrawRect({12+int(12-6*timeRatio),0},{int(6*timeRatio),int(21)},{255,0,0,uint8_t(timeRatio*255)}) //Right
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef RIGHT
|
|
|
|
if(smx.GetPanel(RIGHT,0).bHeld){
|
|
|
|
FillRect({8,7},{3,6},{VERY_DARK_MAGENTA.r,VERY_DARK_MAGENTA.g,VERY_DARK_MAGENTA.b,64});
|
|
|
|
DrawRect({8,7},{3,6},VERY_DARK_MAGENTA);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(UP,0).bHeld){
|
|
|
|
FillRect({4,0},{3,6},{VERY_DARK_MAGENTA.r,VERY_DARK_MAGENTA.g,VERY_DARK_MAGENTA.b,64});
|
|
|
|
DrawRect({4,0},{3,6},VERY_DARK_MAGENTA);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(DOWN,0).bHeld){
|
|
|
|
FillRect({4,14},{3,6},{VERY_DARK_MAGENTA.r,VERY_DARK_MAGENTA.g,VERY_DARK_MAGENTA.b,64});
|
|
|
|
DrawRect({4,14},{3,6},VERY_DARK_MAGENTA);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(LEFT,0).bHeld){
|
|
|
|
FillRect({0,7},{3,6},{VERY_DARK_MAGENTA.r,VERY_DARK_MAGENTA.g,VERY_DARK_MAGENTA.b,64});
|
|
|
|
DrawRect({0,7},{3,6},VERY_DARK_MAGENTA);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(RIGHT,1).bHeld){
|
|
|
|
FillRect({20,7},{3,6},{VERY_DARK_CYAN.r,VERY_DARK_CYAN.g,VERY_DARK_CYAN.b,64});
|
|
|
|
DrawRect({20,7},{3,6},VERY_DARK_CYAN);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(UP,1).bHeld){
|
|
|
|
FillRect({16,0},{3,6},{VERY_DARK_CYAN.r,VERY_DARK_CYAN.g,VERY_DARK_CYAN.b,64});
|
|
|
|
DrawRect({16,0},{3,6},VERY_DARK_CYAN);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(DOWN,1).bHeld){
|
|
|
|
FillRect({16,14},{3,6},{VERY_DARK_CYAN.r,VERY_DARK_CYAN.g,VERY_DARK_CYAN.b,64});
|
|
|
|
DrawRect({16,14},{3,6},VERY_DARK_CYAN);
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(LEFT,1).bHeld){
|
|
|
|
FillRect({12,7},{3,6},{VERY_DARK_CYAN.r,VERY_DARK_CYAN.g,VERY_DARK_CYAN.b,64});
|
|
|
|
DrawRect({12,7},{3,6},VERY_DARK_CYAN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(smx.GetPanel(RIGHT,0).bReleased||smx.GetPanel(LEFT,0).bReleased||smx.GetPanel(UP,0).bReleased||smx.GetPanel(DOWN,0).bReleased){
|
|
|
|
p1.consecutiveNotesHit++;
|
|
|
|
p1.lastNoteHit=0.f;
|
|
|
|
}
|
|
|
|
if(smx.GetPanel(RIGHT,1).bReleased||smx.GetPanel(LEFT,1).bReleased||smx.GetPanel(UP,1).bReleased||smx.GetPanel(DOWN,1).bReleased){
|
|
|
|
p2.consecutiveNotesHit++;
|
|
|
|
p2.lastNoteHit=0.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p1.lastNoteHit>=10.f){
|
|
|
|
p1.consectiveNotesHit=0;
|
|
|
|
}
|
|
|
|
if(p2.lastNoteHit>=10.f){
|
|
|
|
p2.consectiveNotesHit=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p1.consectiveNotesHit>=100){
|
|
|
|
p1.idleTime=0.f;
|
|
|
|
p1.alertActive=false;
|
|
|
|
}
|
|
|
|
if(p2.consectiveNotesHit>=100){
|
|
|
|
p2.idleTime=0.f;
|
|
|
|
p2.alertActive=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p1.idleTime>=160.f){
|
|
|
|
p1.alertActive=true;
|
|
|
|
//PLAY SOUND HERE!!
|
|
|
|
}
|
|
|
|
if(p2.idleTime>=160.f){
|
|
|
|
p2.alertActive=true;
|
|
|
|
//PLAY SOUND HERE!!
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPixelMode(Pixel::MASK);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
SMX_PGE demo;
|
|
|
|
if (demo.Construct(24, 21, 50, 50,false,true))
|
|
|
|
demo.Start();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|