Bad apple video player.

badapple
sigonasr2 2 months ago
parent 04636be072
commit f9fa215051
  1. 56
      sample/PGEX_SMX_Example.cpp
  2. 4
      sample/SMXSample.vcxproj

@ -12,56 +12,32 @@ class SMX_PGE : public olc::PixelGameEngine
public: public:
SMX_PGE() SMX_PGE()
{ {
sAppName = "SMX PGE"; sAppName = "SMX PGE - Bad Apple";
} }
std::vector<Renderable>video;
int currentFrame{0};
double elapsedTime{0.f};
public: public:
bool OnUserCreate() override bool OnUserCreate() override
{ {
// Called once at the start, so create things here // 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; return true;
} }
bool OnUserUpdate(float fElapsedTime) override bool OnUserUpdate(float fElapsedTime) override
{ {
smx.GetPanel(RIGHT, 0).bHeld; Clear(BLACK);
if (GetKey(RIGHT).bPressed) { elapsedTime+=fElapsedTime;
mode = (mode + 1) % 3; const int frame{int(std::clamp((elapsedTime-5)/(1/30.f),1.,6573.))};
} DrawSprite({},video[frame-1].Sprite());
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;
}
return true; return true;
} }
}; };
@ -70,7 +46,7 @@ public:
int main() int main()
{ {
SMX_PGE demo; SMX_PGE demo;
if (demo.Construct(12, 21, 50, 50)) if (demo.Construct(24, 21, 50, 50,false,true))
demo.Start(); demo.Start();
return 0; return 0;

@ -62,7 +62,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <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> <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> <AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -81,7 +81,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <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> <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> <AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

Loading…
Cancel
Save