forked from WenlinMao/SleepWalking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerStats.cpp
More file actions
51 lines (41 loc) · 1.48 KB
/
Copy pathPlayerStats.cpp
File metadata and controls
51 lines (41 loc) · 1.48 KB
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
#include "Inivar.hpp"
#include "PlayerStats.hpp"
#include <iostream>
#include <glm/gtx/string_cast.hpp>
PlayerStats::PlayerStats()
{
direction = 1;
canJump = false;
health = 100.f;
rotMat = glm::mat3(1.f);
}
void PlayerStats::reset()
{
direction = 1;
canJump = false;
health = 100.f;
rotMat = glm::mat3(1.f);
jumpElapsed = 0.f;
player1Light = std::max(player1SavedLight, 4.0f);
player2Light = std::max(player2SavedLight, 4.0f);
std::cout << "Player 1 Light: " << player1Light << std::endl;
std::cout << "Player 2 Light: " << player2Light << std::endl;
}
void PlayerStats::update(float elapsed)
{
player1Light = std::min(MAX_LIGHT_AMOUNT, std::max(player1Light - LIGHT_DECAY * elapsed, 0.f));
player2Light = std::min(MAX_LIGHT_AMOUNT, std::max(player2Light - LIGHT_DECAY * elapsed, 0.f));
player1LightEnergy = player1Light / 5.0f;
player2LightEnergy = player2Light / 5.0f;
ambientLightEnergy = std::min((player1LightEnergy + player2LightEnergy) / 2.f, 1.0f);
if (player1Light == 0.f && player2Light == 0.f) health = 0.f;
}
void PlayerStats::to_string() {
std::cout << "\n\n-----------------------\n";
std::cout << "Printing Player Stats" << std::endl;
std::cout << "Player Health: " << health << std::endl;
std::cout << "Player Light Num: " << lightNum << std::endl;
std::cout << "Player 1 Position: " << glm::to_string(player1Pos) << std::endl;
std::cout << "Player 2 Position: " << glm::to_string(player2Pos) << std::endl;
std::cout << "-----------------------\n\n\n";
}