-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClimbingWall.cpp
52 lines (46 loc) · 1.27 KB
/
ClimbingWall.cpp
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
#include "ClimbingWall.h"
#include "Lemming.h"
ClimbingWall::ClimbingWall(const sf::Vector2f pos, const sf::Vector2f size, const std::string str, const int side)
:StaticObject(pos, size, str), m_side(side)
{
m_object.scale((size.x / m_object.getGlobalBounds().width) + 0.119f + 1.f,
(size.y / m_object.getGlobalBounds().height));
}
ClimbingWall::~ClimbingWall()
{
}
int ClimbingWall::getSide() const
{
return m_side;
}
bool ClimbingWall::collide(GameObject & other, GameBoard & board)
{
return other.collide(*this, board);
}
bool ClimbingWall::collide(Lemming & other, GameBoard & board)
{
sf::Uint8 t;
if (other.getState() == dig)//endel dig stairs
{
t = this->m_object.getColor().a;
if (t == 0)
getSetActive() = false;
else
this->m_object.setColor(sf::Color(255, 255, 255, sf::Uint8(t - 0.05)));
}
if (other.getDirection() == right)//the stairs givs the lemibg the option to climb on them
{
if (getGlobalBounds().contains(other.getCordinate(up_r)))//Checks that the lemming is in range to get a climb
{
other.set_tool(climb);
}
}
else
{
if (getGlobalBounds().contains(other.getCordinate(up_l)))//Checks that the lemming is in range to get a climb
{
other.set_tool(climb);
}
}
return false;
}