A repository that sets up a C++ Project with the olcPixelGameEngine already loaded.
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.
 
 
 

59 lines
1.3 KiB

#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
//--------------------------------------------------------------------------------------------------
// class
//--------------------------------------------------------------------------------------------------
class PressDetect : public olc::PixelGameEngine
{
public:
PressDetect()
{
sAppName = "Double Press Down Detect";
}
private:
bool bothKeysPressed=false;
public:
bool OnUserCreate() override
{
return true;
}
//--------------------------------------------------------------------------------------------------
// Main Game Function
//--------------------------------------------------------------------------------------------------
bool OnUserUpdate(float fElapsedTime) override
{
if (GetKey(olc::SHIFT).bHeld&&GetKey(olc::A).bHeld&&!bothKeysPressed) {
bothKeysPressed=true;
std::cout<<"Both Keys pressed\n";
}
if (bothKeysPressed&&(GetKey(olc::SHIFT).bReleased||GetKey(olc::A).bReleased)) {
bothKeysPressed=false;
std::cout<<"Both Keys released\n";
}
Clear(olc::VERY_DARK_BLUE);
DrawRect({32,32},{32,32},(bothKeysPressed)?olc::YELLOW:olc::BLACK);
return true;
}
};
int main()
{
PressDetect game;
if (game.Construct(256, 240, 4, 4))
game.Start();
return 0;
}