Skip to content

Commit

Permalink
Fix restarting without modifying anything
Browse files Browse the repository at this point in the history
  • Loading branch information
Spejik authored and Spejik committed Aug 23, 2022
1 parent 52c408a commit b8f6255
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions toustovač.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
static float sxm = 1.4;
static float sym = 1.4;
static float fs = false;
static bool loop = true;

// Override base class with your custom functionality
class Bramborak : public olc::PixelGameEngine
Expand Down Expand Up @@ -39,15 +40,15 @@ class Bramborak : public olc::PixelGameEngine
if ((canUpdate += elapsedTime) < 0.1)
if (elapsedTime < mindelta) { mindelta -= 0.00001f; g = (g + 25) % 256; }
else if (elapsedTime > maxdelta) { maxdelta += 0.00001f; r = (r + 25) % 256; }
else if (elapsedTime > mindelta && elapsedTime < maxdelta) { mindelta *= 50.0f; maxdelta /= 50.0f; b = (b + 25) % 256; }
else if (elapsedTime > mindelta && elapsedTime < maxdelta) { mindelta *= 69.0f; maxdelta /= 69.0f; b = (b + 25) % 256; }
else { r = (r + 5) % 256; g = (g + 5) % 256; b = (b + 5) % 256; }
else if ((canUpdate += elapsedTime) > 0.5f)
else if ((canUpdate += elapsedTime) > 0.2f)
{
canUpdate = 0.0f;
mindelta = maxdelta = elapsedTime;
}

if (std::fmod(canUpdate, 0.1) < 0.05)
if (std::fmod(canUpdate, 0.05) < 0.02)
{
if (r0 > r) r0 -= 1;
else if (r0 < r)r0 += 1;
Expand All @@ -68,29 +69,29 @@ class Bramborak : public olc::PixelGameEngine
if (GetKey(olc::F).bReleased)
{
fs = !fs;
loop = true;
olc_Terminate();
return true;
}
}
if (hx = GetKey(olc::X).bHeld)
{
DrawString({ 20, 40 }, "Modifiyng: X", olc::Pixel(256 - r0, 256 - g0, 256 - b0), 2);
DrawString({ 20, 40 }, "Modifying: X", olc::Pixel(256 - r0, 256 - g0, 256 - b0), 2);
}
if (hy = GetKey(olc::Y).bHeld)
{
DrawString({ 20, 60 }, "Modifiyng: Y", olc::Pixel(256 - r0, 256 - g0, 256 - b0), 2);
DrawString({ 20, 60 }, "Modifying: Y", olc::Pixel(256 - r0, 256 - g0, 256 - b0), 2);
}
if (GetKey(olc::NP_ADD).bReleased)
{
if (hx) sxm = std::clamp(sxm += 0.2, 0.1f, 5.0f);
if (hy) sym = std::clamp(sym += 0.2, 0.1f, 5.0f);
olc_Terminate();
if (hx) sxm = std::clamp(sxm += 0.2, 0.2f, 6.0f);
if (hy) sym = std::clamp(sym += 0.2, 0.2f, 6.0f);
if (hx || hy) { loop = true; olc_Terminate(); }
}
else if (GetKey(olc::NP_SUB).bReleased)
{
if (hx) sxm = std::clamp(sxm -= 0.2, 0.1f, 5.0f);
if (hy) sym = std::clamp(sym -= 0.2, 0.1f, 5.0f);
olc_Terminate();
if (hx) sxm = std::clamp(sxm -= 0.2, 0.2f, 6.0f);
if (hy) sym = std::clamp(sym -= 0.2, 0.2f, 6.0f);
if (hx || hy) { loop = true; olc_Terminate(); }
}

return true;
Expand All @@ -100,12 +101,14 @@ class Bramborak : public olc::PixelGameEngine
int main()
{
a_terrible_loop:
auto a = 1920.0f * sxm;
auto b = 1080.0f * sym;
loop = !loop;
int32_t a = 1920 * sxm;
int32_t b = 1080 * sym;
Bramborak tortila(a, b);
std::cout << a << 'x' << b << std::endl;
std::cout << std::format("{}x{}:{}", a, b, fs) << std::endl;
if (tortila.Construct(a, b, 1, 1, fs))
if (tortila.Start() == olc::rcode::OK)
goto a_terrible_loop;
tortila.Start();
if (loop)
goto a_terrible_loop;
return 0;
}

0 comments on commit b8f6255

Please sign in to comment.