-
Notifications
You must be signed in to change notification settings - Fork 0
/
CGame_Loop.cpp
49 lines (35 loc) · 1.29 KB
/
CGame_Loop.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
#include "CGame.h"
#include "CAreaScoring.h"
#include "CEventsManager.h"
void CGame::Loop()
{
// Run any Managed Events
CEventsManager::EventsManager.Loop();
// Run each item in entity list
int size = CEntity::EntityList.size();
for (int i = 0; i < size; i++)
{
if(!CEntity::EntityList[i]) continue;
CEntity::EntityList[i]->Loop();
}
//Collision Events
for(std::vector<CEntityCollision>::iterator it = CEntityCollision::EntityCollisionList.begin();it != CEntityCollision::EntityCollisionList.end(); ++it)
{
if (it->Complete == false)
{
CEntity* EntityA = it->EntityA;
CEntity* EntityB = it->EntityB;
if(EntityA == NULL || EntityB == NULL) continue;
if(EntityA->OnCollision(EntityB))
EntityB->OnCollision(EntityA);
// Remove this and it's pair from the list by marking them as Complete
it->RemoveCollision(EntityA, EntityB);
}
}
CEntityCollision::EntityCollisionList.clear();
// Handle scoring & Timing
CAreaScoring::AreaScoring.Loop();
CLevel::Level.GetCurrentArea()->Loop();
// Give some CPU back
SDL_Delay(1);
}