-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelSystem.cpp
More file actions
27 lines (26 loc) · 1.29 KB
/
Copy pathLevelSystem.cpp
File metadata and controls
27 lines (26 loc) · 1.29 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
#include "LevelSystem.h"
void LevelSystem::Update(){
//updates the level only when necessary
//makes sure that all the levelelements that were above a deleted target or box fall down
if(engine_->GetContext().NeedLevelUpdate){
std::vector<std::vector<Entity*>> levelmatrix = engine_->GetContext().levelmatrix_;
for(int x = 0;x<8;x++){
for(int y = 7;y>=0;y--){
if(levelmatrix[x][y]==NULL){
for(int yi = y + 1;yi<8;yi++){
if(levelmatrix[x][yi]!=NULL){
PositionComponent* pc = dynamic_cast<PositionComponent*>(levelmatrix[x][yi]->GetComponent(Component::POSITION));
LevelElementComponent* lec = dynamic_cast<LevelElementComponent*>(levelmatrix[x][yi]->GetComponent(Component::LEVELELEMENT));
lec->matrixPosition = lec->matrixPosition - Point(0,1);
pc->position = pc->position - Point(0,35);
}
levelmatrix[x][yi-1] = levelmatrix[x][yi];
}
levelmatrix[x][7] = NULL;
}
}
}
engine_->GetContext().levelmatrix_ = levelmatrix;
engine_->GetContext().NeedLevelUpdate = false;
}
}