-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeavyObstacle.cpp
More file actions
75 lines (64 loc) · 1.77 KB
/
HeavyObstacle.cpp
File metadata and controls
75 lines (64 loc) · 1.77 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
71
72
73
74
75
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* HeavyObstacle.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dzui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/05 21:36:10 by dzui #+# #+# */
/* Updated: 2017/11/05 21:36:11 by dzui ### ########.fr */
/* */
/* ************************************************************************** */
#include "HeavyObstacle.hpp"
#include "GameClass.hpp"
HeavyObstacle::HeavyObstacle()
{
posX = 0;
posY = 0;
hp = 0;
map_nb = 3;
}
HeavyObstacle::~HeavyObstacle()
{
}
void HeavyObstacle::generatePosition(int **map)
{
posY = 1 + std::rand() % HEIGHT / 8;
posX = 1 + std::rand() % WIDTH;
while (map[posY][posX] != 0)
{
posY = 1 + std::rand() % HEIGHT / 8;
posX = 1 + std::rand() % WIDTH;
}
map[posY][posX] = map_nb;
setHP();
}
void HeavyObstacle::setHP()
{
hp = 2;
}
int HeavyObstacle::getMap_Nb() const
{
return (map_nb);
}
HeavyObstacle::HeavyObstacle(int **map)
{
hp = 2;
map_nb = 3;
generatePosition(map);
}
HeavyObstacle::HeavyObstacle(const HeavyObstacle &ho)
{
hp = ho.hp;
posY = ho.posY;
posX = ho.posX;
map_nb = ho.map_nb;
}
HeavyObstacle &HeavyObstacle::operator=(const HeavyObstacle &ho)
{
posX = ho.posX;
posY = ho.posY;
map_nb = ho.map_nb;
hp = ho.hp;
return (*this);
}