-
Notifications
You must be signed in to change notification settings - Fork 0
/
character.h
93 lines (78 loc) · 2.64 KB
/
character.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
/*
* A character holds the following information:
* Current health, Current texture, and Current state
*/
#ifndef CHARACTER_H
#define CHARACTER_H
#include "includes/status.hpp"
#include "includes/events.hpp"
#include <string>
#include <memory>
#include <utility>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include "textures.h"
using namespace status;
class Character
{
public:
/*
* This is the constructor for each character. It will initialize all needed
* variables.
* @param const std::string &name - the name of the character being used
* @param unsigned int player - Player 1 or Player 2, used to initialize
* textures
*/
Character( const std::string &name, unsigned int player );
~Character( void );
/*
* This function will update all the current information for the character
* including: current health, current texture, and current state
* @param const STATE &state - The new state to be updated to
* @param char facing - Which way the character is facing, R or L
*/
void update( const STATE &state, char facing );
/*
* This function get the current value of the characters health
* @return unsigned int - The characters current health
*/
float get_health( void );
/*
* This function is used to get the current texture that the character is
* using
*
* @return shared_ptr<Texture> - The characters current texture
*/
std::shared_ptr<sf::Texture> get_texture( void );
/*
* This function is used to get the current state that the character is in
*
* @return pair<STATE, unsigned int> - The current state of the character and
* what texture of that state we are in
*/
std::pair<STATE, unsigned int> get_state( void );
private:
std::string _name;
float _cur_health;
std::shared_ptr<sf::Texture> _character_texture;
// right now there are no images above 32
std::string _image_names[40];
// an object to hold all the textures for the given character
Textures _textures;
STATE _state;
/* HIT is the largest status so we will be able to just index the array based
* on status to find out what index of the status we are in the plus one is
* because we need HIT to be accessable and not out of bounds since the array
* is zero based
*/
unsigned int _execution_position[HIT + 1];
// the sub-image counts for each image/position
std::unordered_map<std::string, unsigned int> _position_counts;
void set_position_counts( const std::string &name );
};
#endif /*CHARACTER_H*/