|
|
|
#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
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<vf2d>snow;
|
|
|
|
std::vector<vf2d>backgroundSnow;
|
|
|
|
|
|
|
|
float backgroundSnowIntervalTimer{0.03f};
|
|
|
|
float backgroundSnowDirectionInterval{60.f};
|
|
|
|
|
|
|
|
#define RIGHT true
|
|
|
|
bool backgroundSnowDirection{RIGHT};
|
|
|
|
float snowInterval{0.8f};
|
|
|
|
float snowTimer{snowInterval};
|
|
|
|
const float snowIntervalChangeInterval{60.f};
|
|
|
|
float snowIntervalTimer{snowIntervalChangeInterval};
|
|
|
|
double totalElapsedTime{};
|
|
|
|
|
|
|
|
float fallSpd{6.f};
|
|
|
|
float snowAmplitude{2.f};
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override
|
|
|
|
{
|
|
|
|
Clear({0,0,32});
|
|
|
|
backgroundSnowIntervalTimer-=fElapsedTime;
|
|
|
|
snowTimer-=fElapsedTime;
|
|
|
|
snowIntervalTimer-=fElapsedTime;
|
|
|
|
if(snowTimer<=0.f){
|
|
|
|
snow.emplace_back(util::random(ScreenWidth()),-2.f);
|
|
|
|
snowTimer=snowInterval;
|
|
|
|
}
|
|
|
|
if(backgroundSnowIntervalTimer<=0.f){
|
|
|
|
backgroundSnowIntervalTimer=snowIntervalTimer*26.66666667f;
|
|
|
|
}
|
|
|
|
if(snowIntervalTimer<=0.f){
|
|
|
|
snowInterval=util::random_range(0.1f,2.f);
|
|
|
|
snowIntervalTimer=snowIntervalChangeInterval;
|
|
|
|
}
|
|
|
|
for(int ind{0};vf2d&snow:snow){
|
|
|
|
snow.y+=fallSpd*fElapsedTime;
|
|
|
|
srand(ind);
|
|
|
|
FillCircle(vi2d{int(snow.x+sin(totalElapsedTime+ind*0.5f*fallSpd)*snowAmplitude),int(snow.y)},rand()%2+1,{uint8_t(200+rand()%55),uint8_t(235+rand()%20),255});
|
|
|
|
ind++;
|
|
|
|
}
|
|
|
|
totalElapsedTime=fmod(totalElapsedTime+fElapsedTime,10000.);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
SMX_PGE demo;
|
|
|
|
if (demo.Construct(24, 21, 50, 50))
|
|
|
|
demo.Start();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|