-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollisionManager.cpp
More file actions
90 lines (74 loc) · 1.93 KB
/
Copy pathCollisionManager.cpp
File metadata and controls
90 lines (74 loc) · 1.93 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "commons.h"
#include "utils.h"
#include "CollisionManager.h"
#include "Conversions.h"
#include "LevelManager.h"
#include <cml/cml.h>
using namespace game_objects;
using namespace game_utils;
using namespace cml;
using namespace utils;
namespace game_utils
{
namespace managers
{
CCollisionManager::CCollisionManager(): CManager()
{
}
CCollisionManager::~CCollisionManager()
{
}
bool CCollisionManager::init()
{
return true;
}
GLvoid CCollisionManager::check(CEntity *entity, cml::vector2i blockPos)
{
}
bool CCollisionManager::update()
{
CEntity *entity;
for (entityIter=T_entities.begin(); entityIter!=T_entities.end(); ++entityIter)
{
entity = *entityIter;
/*
Check entities with terrain end make proper response,
all 4 must be checked since we ce be in the corner.
*/
if (entity->isActive())
{
// 1. get logical position
vector2i pos = CConversions::realToLogical(entity->getPosition());
// 2. extract proper planes of nearby block
check(entity,pos+vector2i(0,-1));
check(entity,pos+vector2i(0,1));
check(entity,pos+vector2i(-1,0));
check(entity,pos+vector2i(1,0));
/* ? check(entity,pos+vector2i(1,1));
check(entity,pos+vector2i(1,-1));
check(entity,pos+vector2i(-1,-1));
check(entity,pos+vector2i(-1,1)); ? */
// just clamp entity to the bottom if we are below min level
vector3f ePos = entity->getPosition();
if (ePos[1]<CV_CAMERA_MIN_FPS_Y_POS)
{
ePos[1] = CV_CAMERA_MIN_FPS_Y_POS;
entity->setPosition(ePos);
}
}
}
return true;
}
bool CCollisionManager::shutdown()
{
return true;
}
GLvoid CCollisionManager::registerEntity_T(CEntity *entity)
{
T_entities.push_back(entity);
}
GLvoid CCollisionManager::registerEntity_O(CEntity *entity)
{
}
}
}