-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightObstacle.cpp
More file actions
69 lines (60 loc) · 1.71 KB
/
LightObstacle.cpp
File metadata and controls
69 lines (60 loc) · 1.71 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* LightObstacle.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dzui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/05 21:33:49 by dzui #+# #+# */
/* Updated: 2017/11/05 21:33:52 by dzui ### ########.fr */
/* */
/* ************************************************************************** */
#include "LightObstacle.hpp"
#include "GameClass.hpp"
LightObstacle::LightObstacle()
{
posX = 0;
posY = 0;
hp = 0;
map_nb = 2;
}
LightObstacle::~LightObstacle()
{
}
void LightObstacle::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 LightObstacle::setHP()
{
hp = 2;
}
LightObstacle::LightObstacle(int **map)
{
hp = 1;
map_nb = 2;
generatePosition(map);
}
LightObstacle::LightObstacle(const LightObstacle &lo)
{
hp = lo.hp;
posY = lo.posY;
posX = lo.posX;
map_nb = lo.map_nb;
}
LightObstacle &LightObstacle::operator=(const LightObstacle &lo)
{
posX = lo.posX;
posY = lo.posY;
map_nb = lo.map_nb;
hp = lo.hp;
return (*this);
}