zad5 ok
This commit is contained in:
parent
59ee167f93
commit
a0197ad79f
@ -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<float>(Settings.MaxJumpHeight),
|
||||
static_cast<float>(Settings.HorizontalDistanceToMaxJumpHeight),
|
||||
static_cast<float>(Settings.BgPrl0),
|
||||
static_cast<float>(Settings.BgPrl1),
|
||||
static_cast<float>(Settings.BgPrl2),
|
||||
static_cast<float>(Settings.JumpInitialVelocity),
|
||||
static_cast<float>(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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<float, KSettings> MaxJumpHeight, HorizontalDistanceToMaxJumpHeight;
|
||||
const Property<float, KSettings> MaxJumpHeight, HorizontalDistanceToMaxJumpHeight, BgPrl0, BgPrl1, BgPrl2;
|
||||
const ReadOnlyProperty<float, KSettings> TimeToMaxHeight, Gravity, JumpInitialVelocity, ShortJumpVelocity;
|
||||
const Property<bool, KSettings> 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();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
BIN
2dkg_zad5/assets_src/mptiles.pdn
(Stored with Git LFS)
Normal file
BIN
2dkg_zad5/assets_src/mptiles.pdn
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user