-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructex.cpp
More file actions
58 lines (47 loc) · 921 Bytes
/
structex.cpp
File metadata and controls
58 lines (47 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
using namespace std;
struct LocationVector
{
float X;
float Y;
float Z;
};
struct Player
{
int Level;
float Health;
float Damage;
float Stamina;
LocationVector location = { 0.f,0.f,0.f };
void TakeDamage(float dmg)
{
Health -= dmg;
}
int GetLevel()
{
if (Level > 10) {
cout << " Level is greater than 10! ";
}
return Level;
}
void DisplayLocation()
{
cout << "X location " << location.X << endl;
cout << "Y location " << location.Y << endl;
cout << "Z location " << location.Z << endl;
}
};
int main()
{
Player p_1;
p_1.Level = 12;
p_1.Health = 100.f;
p_1.Damage = 10.f;
p_1.Stamina = 20.f;
cout << p_1.GetLevel() << " \nplayer 1 level\n" << endl;
p_1.TakeDamage(40.f);
cout << "p_1 Health now is " << p_1.Health << endl;
p_1.DisplayLocation();
Player p_2 = { 1,50.f,40.f,35.54f,{35.56f,67.2f,100.003f} };
p_2.DisplayLocation();
}