Compare commits

...

1 Commits

Author SHA1 Message Date
sigonasr2 f9fa215051 Bad apple video player. 2 months ago
  1. 56
      sample/PGEX_SMX_Example.cpp
  2. 4
      sample/SMXSample.vcxproj

@ -12,56 +12,32 @@ class SMX_PGE : public olc::PixelGameEngine
public:
SMX_PGE()
{
sAppName = "SMX PGE";
sAppName = "SMX PGE - Bad Apple";
}
std::vector<Renderable>video;
int currentFrame{0};
double elapsedTime{0.f};
public:
bool OnUserCreate() override
{
// Called once at the start, so create things here
const std::string badAppleVideoDir{"badapple"};
for(int frame=1;frame<=6572;frame++){
video.emplace_back();
video[frame-1].Load(std::format("{}/frame{}.png",badAppleVideoDir,frame));
}
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
smx.GetPanel(RIGHT, 0).bHeld;
if (GetKey(RIGHT).bPressed) {
mode = (mode + 1) % 3;
}
switch (mode) {
case 0: {
if (GetKey(SPACE).bPressed) {
paused = !paused;
}
// called once per frame
if (!paused) {
for (int x = 0; x < ScreenWidth(); x++)
for (int y = 0; y < ScreenHeight(); y++)
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand() % 255));
}
}break;
case 1: {
Clear(DARK_CYAN);
DrawRect({ 1,1 }, { 9,18 }, RED);
}break;
case 2: {
Clear(VERY_DARK_BLUE);
FillCircle(playerPos, 3,VERY_DARK_GREY);
DrawCircle(playerPos, 3);
if (GetKey(W).bHeld) {
playerPos.y -= 5*fElapsedTime;
}
if (GetKey(A).bHeld) {
playerPos.x -= 5 * fElapsedTime;
}
if (GetKey(S).bHeld) {
playerPos.y += 5 * fElapsedTime;
}
if (GetKey(D).bHeld) {
playerPos.x += 5 * fElapsedTime;
}
}break;
}
Clear(BLACK);
elapsedTime+=fElapsedTime;
const int frame{int(std::clamp((elapsedTime-5)/(1/30.f),1.,6573.))};
DrawSprite({},video[frame-1].Sprite());
return true;
}
};
@ -70,7 +46,7 @@ public:
int main()
{
SMX_PGE demo;
if (demo.Construct(12, 21, 50, 50))
if (demo.Construct(24, 21, 50, 50,false,true))
demo.Start();
return 0;

@ -62,7 +62,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -81,7 +81,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

Loading…
Cancel
Save