-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.h
111 lines (79 loc) · 2.96 KB
/
player.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef PLAYER_H
#define PLAYER_H
#include <cmath>
#include <SFML/Graphics.hpp>
#include "amino_acid.h"
#include "bullet.h"
#include "power_type.h"
class player
{
public:
player(
amino_acid any_amino_acid,
const double x = 0.0,
const double y = 0.0
);
void accelerate();
void decelerate();
auto get_amino_acid() const noexcept { return m_amino_acid; }
auto get_hp() const noexcept { return m_hp; }
///Return the special power of the amino acid
auto get_rotation() const noexcept { return m_rotation_deg; }
auto get_shoot_ability() const noexcept { return m_able_to_shoot; }
std::pair<double, double> get_speed() const noexcept { return { m_speed_x, m_speed_y }; }
auto get_speed_x() const noexcept { return m_speed_x; }
auto get_speed_y() const noexcept { return m_speed_y; }
auto get_turn_speed() const noexcept { return m_turn_speed_deg_per_tick; }
auto get_x() const noexcept { return m_x; }
auto get_y() const noexcept { return m_y; }
///Is the player currenly using a power
bool is_using_power() const noexcept;
void move(const double world_size);
void set_amino_acid(const amino_acid aminoacid) { m_amino_acid = aminoacid; }
void set_hp(const double hp) { m_hp = hp; }
void set_position(const double x, const double y) noexcept { m_x = x; m_y = y; }
///Set the angle/rotation of the player
void set_rotation(const double r) noexcept { m_rotation_deg = r; }
///Set the horizontal speed
void set_speed_x(double speed) { m_speed_x = speed; }
///Set the vertical speed
void set_speed_y(double speed) { m_speed_y = speed; }
///Set the turning speed
void set_turn_speed(double turn_speed) { m_turn_speed_deg_per_tick = turn_speed; }
///When a player starts using a power, the game logic 'game' may be modified
void start_using_power();
///When a player its power ends, the game logic 'game' may be modified
void stop_using_power();
void turn_left();
void turn_right();
void lose_hp();
void unable_to_shoot() { m_able_to_shoot = false; }
private:
bool m_able_to_shoot;
amino_acid m_amino_acid;
double m_hp;
/// The angle the player has, in degrees
double m_rotation_deg;
/// Horizontal speed in pixels per tick
double m_speed_x;
/// Vertical speed in pixels per tick
double m_speed_y;
///How fast the sprite is rotating per tick
double m_turn_speed_deg_per_tick;
///Is the player using its power?
bool m_uses_power;
double m_x;
double m_y;
};
/// Get the radius that each player has around its center
/// in which is is hit, in pixels
double get_hit_range_size();
std::pair<double, double> get_position(const player& p) noexcept;
power_type get_power(const amino_acid any_aa) noexcept;
///Creat a bullet shot by the player
bullet create_new_bullet(const player& any_player);
///Set movement speed to zero
void stop(player& p);
bool operator==(const player& lhs, const player& rhs) noexcept;
std::ostream& operator<<(std::ostream& os, const player& any_player) noexcept;
#endif // PLAYER_H