-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
47 lines (41 loc) · 1.11 KB
/
player.cpp
File metadata and controls
47 lines (41 loc) · 1.11 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
#include "player.h"
#include <fstream>
#include <iostream>
Player::Player() {
}
Player::Player(const char *path, std::pair <double, double> p)
{
/* Read player data in following format:
* (hp) (melee damage) (ranged damage) (movement speed x) (height of jump/num of movements in jump)
* (path to pellet data file)
* (number of animation frames) (width of frame) (height of frame)
*
* ...
* (frames)
* ...
*/
pos = p;
std::ifstream fin(path);
fin >> hp >> melee >> ranged >> mov.first >> mov.second;
char next;
while(fin.get(next))
if (next == '\n')
break;
std::getline(fin, pelletPath);
fin >> nFrames >> size.first >> size.second;
jump = 0;
while(fin.get(next))
if (next == '\n')
break;
std::vector <std::string> t;
for (int i = 0; i < nFrames; i++)
texture.push_back(t);
std::string tmp;
for (int i = 0; i < nFrames; i++) {
for (int j = 0; j < size.second; j++) {
std::getline(fin, tmp);
texture[i].push_back(tmp);
}
}
right = true;
}