generated from sigonasr2/CPlusPlusProjectTemplate
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.4 KiB
78 lines
1.4 KiB
#define OLC_GFX_OPENGL33
|
|
#include "pixelGameEngine.h"
|
|
|
|
using namespace olc;
|
|
|
|
#define WIDTH 640
|
|
#define HEIGHT 480
|
|
|
|
class Example : public olc::PixelGameEngine
|
|
{
|
|
float lastIncrease=0.f;
|
|
|
|
public:
|
|
Example()
|
|
{
|
|
sAppName = "Example";
|
|
}
|
|
|
|
public:
|
|
olc::Key last;
|
|
bool OnUserCreate() override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override
|
|
{
|
|
if(lastIncrease==0.f){
|
|
if(GetKey(RIGHT).bHeld){
|
|
SetMosaicEffect(GetMosaicEffect()+1);
|
|
lastIncrease=0.01f;
|
|
}
|
|
if(GetKey(LEFT).bHeld){
|
|
SetMosaicEffect(GetMosaicEffect()-1);
|
|
lastIncrease=0.01f;
|
|
}
|
|
}else{
|
|
lastIncrease=std::max(0.f,lastIncrease-fElapsedTime);
|
|
}
|
|
Clear(BLACK);
|
|
srand(48190);
|
|
for(int i=0;i<500;i++){
|
|
if(rand()%2){
|
|
DrawCircle({rand()%640,rand()%480},rand()%30,{uint8_t(rand()%255),uint8_t(rand()%255),uint8_t(rand()%255)});
|
|
}else{
|
|
FillCircle({rand()%640,rand()%480},rand()%30,{uint8_t(rand()%255),uint8_t(rand()%255),uint8_t(rand()%255)});
|
|
}
|
|
}
|
|
DrawStringDecal({1,1},"Mosaic Effect: "+std::to_string(GetMosaicEffect()),BLACK);
|
|
DrawStringDecal({0,0},"Mosaic Effect: "+std::to_string(GetMosaicEffect()),WHITE);
|
|
return true;
|
|
}
|
|
|
|
bool OnUserDestroy()override{
|
|
return true;
|
|
}
|
|
};
|
|
|
|
enum Direction{
|
|
RIGHT,
|
|
DOWN,
|
|
LEFT,
|
|
UP
|
|
};
|
|
|
|
struct Data{
|
|
int x,y;
|
|
};
|
|
|
|
|
|
int main()
|
|
{
|
|
Example demo;
|
|
if (demo.Construct(640, 480, 4, 4))
|
|
demo.Start();
|
|
|
|
return 0;
|
|
}
|
|
|