Skip to content

Commit 3aa19a1

Browse files
Владимир СеверовВладимир Северов
authored andcommitted
17.05.26 16:09 - Struct edited
1 parent 92e2a53 commit 3aa19a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+396
-374
lines changed

HW-2/Classes/AliveObject.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ aad::AliveObject::AliveObject()
1111
, armorLabel_(nullptr)
1212
{}
1313

14-
aad::AliveObject::AliveObject(GameObject const* parent, float maxHealth, float maxArmor)
14+
aad::AliveObject::AliveObject(GameObject* const parent, float maxHealth, float maxArmor)
1515
: parent_(nullptr)
1616
, health_(0.f)
1717
, maxHealth_(maxHealth)
@@ -39,7 +39,7 @@ void aad::AliveObject::Damage(float power)
3939
}
4040
}
4141

42-
void aad::AliveObject::SetParent(GameObject const * parent)
42+
void aad::AliveObject::SetParent(GameObject* const parent)
4343
{
4444
parent_ = parent;
4545
LabelsInit_();
@@ -66,7 +66,7 @@ void aad::AliveObject::SetArmor(float armor)
6666
}
6767
}
6868

69-
aad::GameObject const * aad::AliveObject::GetParent()
69+
aad::GameObject* aad::AliveObject::GetParent() const
7070
{
7171
return parent_;
7272
}
@@ -139,10 +139,10 @@ void aad::AliveObject::OnYUpdate_()
139139
{
140140
if (parent_ != nullptr) {
141141
if (healthLabel_ != nullptr) {
142-
healthLabel_->setPositionY(parent_->GetY() + parent_->GetH() + MARGIN_SIZE);
142+
healthLabel_->setPositionY(parent_->GetY() + parent_->GetH() + HEALTH_MARGIN);
143143
}
144144
if (armorLabel_ != nullptr) {
145-
armorLabel_->setPositionY(parent_->GetY() + parent_->GetH() + 2 * MARGIN_SIZE + HEALTH_FONT_SIZE);
145+
armorLabel_->setPositionY(parent_->GetY() + parent_->GetH() + 2 * HEALTH_MARGIN + HEALTH_FONT_SIZE);
146146
}
147147
}
148148
}

HW-2/Classes/AliveObject.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@
77

88
namespace aad {
99

10+
const float HEALTH_FONT_SIZE = 30.f;
11+
const float HEALTH_MARGIN = 20.f;
12+
1013
class AliveObject abstract
1114
{
1215
public:
1316
AliveObject();
14-
AliveObject(GameObject const* parent, float maxHealth, float maxArmor);
17+
AliveObject(GameObject* const parent, float maxHealth, float maxArmor);
1518

1619
virtual ~AliveObject() = default;
1720

1821
virtual void Damage(float power);
1922

20-
void SetParent(GameObject const* parent);
23+
void SetParent(GameObject* const parent);
2124
void SetHealth(float health);
2225
void SetArmor(float armor);
2326

24-
GameObject const* GetParent();
27+
GameObject* GetParent() const;
2528
float GetHealth() const;
2629
float GetMaxHealth() const;
2730
float GetArmor() const;
@@ -35,7 +38,7 @@ namespace aad {
3538
virtual void OnRightAlignmentUpdate_();
3639

3740
private:
38-
GameObject const* parent_;
41+
GameObject* parent_;
3942
float health_;
4043
float maxHealth_;
4144
float armor_;

HW-2/Classes/AppDelegate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// #define USE_AUDIO_ENGINE 1
55
// #define USE_SIMPLE_AUDIO_ENGINE 1
6-
#define FULL_SCREEN_MODE 1
6+
#define FULL_SCREEN_MODE 0
77
#if (!FULL_SCREEN_MODE)
88
#define FRAME_SIZE_NAME resolutionSizeNo4
99
#endif

HW-2/Classes/AttackerObject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ aad::AttackerObject::AttackerObject()
88
{}
99

1010
aad::AttackerObject::AttackerObject(float maxHealth, float power, float speed, std::string const& fileName)
11-
: DynamicObject(MARGIN_SIZE, GROUND_HEIGHT, speed, 0.f, fileName)
11+
: DynamicObject(ATTACKER_X_START, ATTACKER_Y_START, speed, 0.f, fileName)
1212
, AliveObject(this, maxHealth, 0.f)
1313
, power_(power)
1414
{}
@@ -31,6 +31,7 @@ void aad::AttackerObject::Update(Game* const scene)
3131
SetX_(GetX() - (ATTACKER_DISTANCE - distance));
3232
}
3333
}
34+
OnPositionUpdate_();
3435
}
3536

3637
void aad::AttackerObject::Attack(Game* const scene)

HW-2/Classes/AttackerObject.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@
77

88
namespace aad {
99

10+
const float ATTACKER_DISTANCE = 1.f;
11+
const float ATTACKER_X_START = 20.f;
12+
const float ATTACKER_Y_START = 80.f;
13+
14+
const float ATTACKER_NO_1_COST = 10.f;
15+
const float ATTACKER_NO_1_HEALTH = 10.f;
16+
const float ATTACKER_NO_1_POWER = 0.2f;
17+
const float ATTACKER_NO_1_SPEED = 1.5f;
18+
const std::string ATTACKER_NO_1_FILE = "attackers/AttackerNo1.png";
19+
20+
const float ATTACKER_NO_2_COST = 40.f;
21+
const float ATTACKER_NO_2_HEALTH = 70.f;
22+
const float ATTACKER_NO_2_POWER = 0.3f;
23+
const float ATTACKER_NO_2_SPEED = 3.f;
24+
const std::string ATTACKER_NO_2_FILE = "attackers/AttackerNo2.png";
25+
26+
const float ATTACKER_NO_3_COST = 90.f;
27+
const float ATTACKER_NO_3_HEALTH = 145.f;
28+
const float ATTACKER_NO_3_POWER = 0.45f;
29+
const float ATTACKER_NO_3_SPEED = 2.5f;
30+
const std::string ATTACKER_NO_3_FILE = "attackers/AttackerNo3.png";
31+
32+
const float ATTACKER_NO_4_COST = 150.f;
33+
const float ATTACKER_NO_4_HEALTH = 175.f;
34+
const float ATTACKER_NO_4_POWER = 0.68f;
35+
const float ATTACKER_NO_4_SPEED = 1.5f;
36+
const std::string ATTACKER_NO_4_FILE = "attackers/AttackerNo4.png";
37+
1038
class AttackerObject abstract
1139
: public DynamicObject, public AliveObject
1240
{

HW-2/Classes/CastleObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ aad::CastleObject::CastleObject()
77
{}
88

99
aad::CastleObject::CastleObject(float maxHealth, std::string const& fileName)
10-
: StaticObject(MARGIN_SIZE, GROUND_HEIGHT, fileName)
10+
: StaticObject(CASTLE_X_POSITION, CASTLE_Y_POSITION, fileName)
1111
, AliveObject(this, maxHealth, 2.f * maxHealth)
1212
{}
1313

HW-2/Classes/CastleObject.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
namespace aad {
99

10+
const float CASTLE_X_POSITION = 20.f;
11+
const float CASTLE_Y_POSITION = 80.f;
12+
13+
const float CASTLE_NO_1_COST = 50.f;
14+
const float CASTLE_NO_1_HEALTH = 300.f;
15+
const std::string CASTLE_NO_1_FILE = "castles/CastleNo1.png";
16+
17+
const float CASTLE_NO_2_COST = 500.f;
18+
const float CASTLE_NO_2_HEALTH = 1000.f;
19+
const std::string CASTLE_NO_2_FILE = "castles/CastleNo2.png";
20+
1021
class CastleObject abstract
1122
: public StaticObject, public AliveObject
1223
{

HW-2/Classes/DynamicObject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ aad::DynamicObject::DynamicObject(float x, float y, float hSpeed, float vSpeed,
2121

2222
void aad::DynamicObject::Update(Game* const scene)
2323
{
24+
GameObject::Update(scene);
25+
2426
SetY_(GetY() + vSpeed_);
2527
SetX_(GetX() + hSpeed_);
26-
GameObject::Update(scene);
28+
OnPositionUpdate_();
2729
}
2830

2931
float aad::DynamicObject::GetHSpeed() const

HW-2/Classes/GameObject.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ aad::GameObject::GameObject(float x, float y, std::string const& fileName)
2929
}
3030

3131
void aad::GameObject::Update(Game * const scene)
32-
{
33-
OnPositionUpdate_();
34-
}
32+
{}
3533

3634
cocos2d::Sprite * aad::GameObject::GetSprite() const
3735
{

HW-2/Classes/GameObject.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,6 @@
66

77
namespace aad {
88

9-
const float ATTACKER_DISTANCE = 0;
10-
const float MARGIN_SIZE = 20.f;
11-
const float HEALTH_FONT_SIZE = 30.f;
12-
const float GROUND_HEIGHT = 80.f;
13-
14-
const float SIMPLE_ATTACKER_COST = 10.f;
15-
const float SIMPLE_ATTACKER_HEALTH = 10.f;
16-
const float SIMPLE_ATTACKER_POWER = 0.2f;
17-
const float SIMPLE_ATTACKER_SPEED = 1.5f;
18-
19-
const float FIRST_ATTACKER_COST = 40.f;
20-
const float FIRST_ATTACKER_HEALTH = 70.f;
21-
const float FIRST_ATTACKER_POWER = 0.3f;
22-
const float FIRST_ATTACKER_SPEED = 3.f;
23-
24-
const float SECOND_ATTACKER_COST = 90.f;
25-
const float SECOND_ATTACKER_HEALTH = 145.f;
26-
const float SECOND_ATTACKER_POWER = 0.45f;
27-
const float SECOND_ATTACKER_SPEED = 2.5f;
28-
29-
const float THIRD_ATTACKER_COST = 150.f;
30-
const float THIRD_ATTACKER_HEALTH = 175.f;
31-
const float THIRD_ATTACKER_POWER = 0.68f;
32-
const float THIRD_ATTACKER_SPEED = 1.5f;
33-
349
class Game;
3510

3611
class GameObject abstract

0 commit comments

Comments
 (0)