-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.cpp
More file actions
70 lines (60 loc) · 1.61 KB
/
Enemy.cpp
File metadata and controls
70 lines (60 loc) · 1.61 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Enemy.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dzui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/05 21:33:03 by dzui #+# #+# */
/* Updated: 2017/11/05 21:33:04 by dzui ### ########.fr */
/* */
/* ************************************************************************** */
#include "Enemy.hpp"
#include "GameClass.hpp"
Enemy::Enemy()
{
posX = 0;
posY = 0;
hp = 0;
map_nb = 0;
}
Enemy::~Enemy()
{
}
Enemy::Enemy(int **map)
{
hp = 1;
map_nb = 4;
generatePosition(map);
}
void Enemy::setHP()
{
hp = 1;
}
void Enemy::generatePosition(int **map)
{
posY = 2 + std::rand() % HEIGHT / 2;
posX = 2 + std::rand() % (WIDTH - 2);
while (map[posY][posX] != 0)
{
posY = 2 + std::rand() % HEIGHT / 2;
posX = 2 + std::rand() % (WIDTH - 2);
}
map[posY][posX] = map_nb;
setHP();
}
Enemy::Enemy(const Enemy &ob)
{
posX = ob.posX;
posY = ob.posY;
hp = ob.hp;
map_nb = ob.map_nb;
}
Enemy &Enemy::operator=(const Enemy &ob)
{
hp = ob.hp;
posY = ob.posY;
posX = ob.posX;
map_nb = ob.map_nb;
return (*this);
}