diff --git a/2dkg_zad5/2dgk_zad5/KGame.cpp b/2dkg_zad5/2dgk_zad5/KGame.cpp index 5ef6b84..7ae51ff 100644 --- a/2dkg_zad5/2dgk_zad5/KGame.cpp +++ b/2dkg_zad5/2dgk_zad5/KGame.cpp @@ -154,7 +154,7 @@ namespace KapitanGame { } if (clip >= 0) Objects.emplace(std::make_pair(static_cast(i), y), std::make_shared(position, Textures["tiles"], &TileClips[clip], flip)); - + break; } } @@ -354,6 +354,36 @@ namespace KapitanGame { Settings.HorizontalDistanceToMaxJumpHeight += 0.1f; SettingsTextTextureDirty = true; } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_5)) + { + Settings.BgPrl0 -= 0.01f; + SettingsTextTextureDirty = true; + } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_6)) + { + Settings.BgPrl0 += 0.01f; + SettingsTextTextureDirty = true; + } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_7)) + { + Settings.BgPrl1 -= 0.01f; + SettingsTextTextureDirty = true; + } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_8)) + { + Settings.BgPrl1 += 0.01f; + SettingsTextTextureDirty = true; + } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_9)) + { + Settings.BgPrl2 -= 0.01f; + SettingsTextTextureDirty = true; + } + if (Input.IsKeyboardButtonHeld(SDL_SCANCODE_0)) + { + Settings.BgPrl2 += 0.01f; + SettingsTextTextureDirty = true; + } } if (Playing) { @@ -388,6 +418,9 @@ namespace KapitanGame { "Collision Enabled (F2): %s\n" "Max Jump Height (F3/F4): %f\n" "Horizontal Distance to Max Jump Height (F5/F6): %f\n" + "BG0 Scroll (5/6): %f\n" + "BG1 Scroll (7/8): %f\n" + "BG2 Scroll (9/0): %f\n" "Initial Jump Velocity: %f\n" "Gravity: %f\n" "Player Position X: %f\n" @@ -396,6 +429,9 @@ namespace KapitanGame { Settings.CollisionEnabled ? "True" : "False", static_cast(Settings.MaxJumpHeight), static_cast(Settings.HorizontalDistanceToMaxJumpHeight), + static_cast(Settings.BgPrl0), + static_cast(Settings.BgPrl1), + static_cast(Settings.BgPrl2), static_cast(Settings.JumpInitialVelocity), static_cast(Settings.Gravity), Pawns.back()->GetPosition().X, @@ -428,7 +464,7 @@ namespace KapitanGame { for (int i = 0; i < Constants::BG_LAYER_COUNT; ++i) { for (const auto& [tile, drawable] : BackgroundLayers[i]) - drawable->Render(Renderer, cameraInUse, 1.f - (Constants::BG_LAYER_COUNT - i - 1) * .25f); //TODO: Add controls for changing parallax factor + drawable->Render(Renderer, cameraInUse, Settings.GetBgPrl(i)); } for (const auto& [tile, obj] : Objects) obj->Render(Renderer, cameraInUse); diff --git a/2dkg_zad5/2dgk_zad5/KSettings.cpp b/2dkg_zad5/2dgk_zad5/KSettings.cpp index 89deca4..f0cd5e6 100644 --- a/2dkg_zad5/2dgk_zad5/KSettings.cpp +++ b/2dkg_zad5/2dgk_zad5/KSettings.cpp @@ -14,8 +14,14 @@ namespace KapitanGame ShortJumpVelocityValue(NAN), CollisionEnabledValue(true), Dirty(true), + BgPrl0Value(0.5f), + BgPrl1Value(0.75f), + BgPrl2Value(1.0f), MaxJumpHeight(this, &KSettings::GetMaxJumpHeight, &KSettings::SetMaxJumpHeight), HorizontalDistanceToMaxJumpHeight(this, &KSettings::GetHorizontalDistanceToMaxJumpHeight, &KSettings::SetHorizontalDistanceToMaxJumpHeight), + BgPrl0(this, &KSettings::GetBgPrl0, &KSettings::SetBgPrl0), + BgPrl1(this, &KSettings::GetBgPrl1, &KSettings::SetBgPrl1), + BgPrl2(this, &KSettings::GetBgPrl2, &KSettings::SetBgPrl2), TimeToMaxHeight(this, &KSettings::GetTimeToMaxHeight), Gravity(this, &KSettings::GetGravity), JumpInitialVelocity(this, &KSettings::GetJumpInitialVelocity), @@ -39,6 +45,22 @@ namespace KapitanGame } } + void KSettings::SetBgPrl0(const float value) { + if (value > 1.f) return; + if (value != BgPrl0Value) + BgPrl0Value = value; + } + void KSettings::SetBgPrl1(const float value) { + if (value > 1.f) return; + if (value != BgPrl1Value) + BgPrl1Value = value; + } + void KSettings::SetBgPrl2(const float value) { + if (value > 1.f) return; + if (value != BgPrl2Value) + BgPrl2Value = value; + } + void KSettings::SetHorizontalDistanceToMaxJumpHeight(const float xn) { if (xn <= 0.f && HorizontalDistanceToMaxJumpHeightValue <= 0.f) return; @@ -95,4 +117,35 @@ namespace KapitanGame { return HorizontalDistanceToMaxJumpHeightValue; } + + float KSettings::GetBgPrl(const int i) { + switch (i) { + case 0: + return GetBgPrl0(); + case 1: + return GetBgPrl1(); + case 2: + return GetBgPrl2(); + + default: return 1; + } + } + + // ReSharper disable once CppMemberFunctionMayBeConst + float KSettings::GetBgPrl0() + { + return BgPrl0Value; + } + + // ReSharper disable once CppMemberFunctionMayBeConst + float KSettings::GetBgPrl1() + { + return BgPrl1Value; + } + + // ReSharper disable once CppMemberFunctionMayBeConst + float KSettings::GetBgPrl2() + { + return BgPrl2Value; + } } diff --git a/2dkg_zad5/2dgk_zad5/KSettings.h b/2dkg_zad5/2dgk_zad5/KSettings.h index 2c160ac..76c0f31 100644 --- a/2dkg_zad5/2dgk_zad5/KSettings.h +++ b/2dkg_zad5/2dgk_zad5/KSettings.h @@ -13,25 +13,36 @@ namespace KapitanGame float ShortJumpVelocityValue; bool CollisionEnabledValue; bool Dirty; + float BgPrl0Value; + float BgPrl1Value; + float BgPrl2Value; public: KSettings(float maxJumpHeight, float horizontalDistanceToMaxJumpHeight); - const Property MaxJumpHeight, HorizontalDistanceToMaxJumpHeight; + const Property MaxJumpHeight, HorizontalDistanceToMaxJumpHeight, BgPrl0, BgPrl1, BgPrl2; const ReadOnlyProperty TimeToMaxHeight, Gravity, JumpInitialVelocity, ShortJumpVelocity; const Property CollisionEnabled; + float GetBgPrl(int i); private: void SetCollisionEnabled(bool value); void SetMaxJumpHeight(float h); + void SetBgPrl0(float prl); + void SetBgPrl1(float prl); + void SetBgPrl2(float prl); void SetHorizontalDistanceToMaxJumpHeight(float xn); bool GetCollisionEnabled(); float GetTimeToMaxHeight(); float GetGravity(); + float GetBgPrl0(); + float GetBgPrl1(); + float GetBgPrl2(); float GetJumpInitialVelocity(); float GetShortJumpVelocity(); float GetMaxJumpHeight(); float GetHorizontalDistanceToMaxJumpHeight(); + }; } diff --git a/2dkg_zad5/2dgk_zad5/assets/levels/level1.txt b/2dkg_zad5/2dgk_zad5/assets/levels/level1.txt index 0fa2acb..a0673f0 100644 --- a/2dkg_zad5/2dgk_zad5/assets/levels/level1.txt +++ b/2dkg_zad5/2dgk_zad5/assets/levels/level1.txt @@ -22,14 +22,14 @@ hg 6g - 44 -4 444 44 4 4 4 44 444 4 -44444 444 4 444 44 44 4444 4 4 4444 4 4 44 4444444444 4444 444 44 -44444 444444444444 4 4444 4444444444444 44444444 4 4444 444444444444 44444444444 4444 -4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 -4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 -4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 -4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 + e4 +4 44e 44 4 4 e e4 444 4 +4e4e4 444 4 444 44 44 4e4e 4 e 4e44 4 4 4e 44ee44e444 4e4e 44e 4e +44e44 4e4e444ee444 4 ee44 4444ee44e44e4 4444e444 4 e444 44e44e44ee44 44e44e4e4e4 e44e +44444e4444e44444e44444e4444e4e4eee444ee4444e4444444e444444e4444e4e44ee4e44e4e4444e4e44444444e4e44ee4 +44e444e44ee4e4444e44e444e4e44ee44e44e44e44e4444e44e444e44e4eee4e4444ee4e444ee444e44ee44e44ee4444e44e +4444444e444e44e44e4e44e444e44e444ee4e44e4e4e44e4e444ee4e4ee44444e4e44444e44e4e4e44e44eeee444e44ee444 +444e44e44444444e44444e44e44e4444e44e44e4444ee444ee4e44ee444444444444e4444e4444e4444444444e444eee44e4 !2 diff --git a/2dkg_zad5/2dgk_zad5/assets/levels/level1_bg.txt b/2dkg_zad5/2dgk_zad5/assets/levels/level1_bg.txt deleted file mode 100644 index ede4de7..0000000 --- a/2dkg_zad5/2dgk_zad5/assets/levels/level1_bg.txt +++ /dev/null @@ -1,15 +0,0 @@ - - - - 3333 - 333344444111 - 3 33144444444411 - 3314444444444444 - 333311444444444444444 - 3333 14444444444444444 - 3 33333 3366666633 14444444444444444 - 33 1144444411 3333 14444444444444444 - 33 11 1144444411 44444444444444444 - P 11 11 1144444411 44444444444444444 -3333333333333333333333333333113333333311333333113333331133333333333333333333333333333333333333333333 -1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 \ No newline at end of file diff --git a/2dkg_zad5/2dgk_zad5/config.json b/2dkg_zad5/2dgk_zad5/config.json index c9a79fb..9d789f0 100644 --- a/2dkg_zad5/2dgk_zad5/config.json +++ b/2dkg_zad5/2dgk_zad5/config.json @@ -7,11 +7,11 @@ "Scale": 1.000000, "Key": "D" }, - { - "AxisName": "MoveX", - "Scale": -1.000000, - "Key": "A" - }, + { + "AxisName": "MoveX", + "Scale": -1.000000, + "Key": "A" + }, { "AxisName": "MoveX", "Scale": 1.000000, diff --git a/2dkg_zad5/assets_src/mptiles.pdn b/2dkg_zad5/assets_src/mptiles.pdn new file mode 100644 index 0000000..26c0be8 --- /dev/null +++ b/2dkg_zad5/assets_src/mptiles.pdn @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84410dc60dd724cf81013f24eaf9ac140455391d57e267625e11a8fe00cdca72 +size 8583