-
Notifications
You must be signed in to change notification settings - Fork 1
/
level.cpp
62 lines (47 loc) · 1.29 KB
/
level.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
53
54
55
56
57
58
59
60
61
62
#include "level.h"
Level::Level(string level)
{
objects = EntityContainer::getInstance();
window = Window::getInstance();
resourceMgr = ResourceMgr::getInstance();
input = Input::getInstance();
player = NULL;
levelFile = level;
isOver = false;
}
void Level::update()
{
player->checkInput();
objects->handleAllOnAlways();
objects->handleAllDetection();
Entity* goal = objects->getEntity("Goal");
if(goal->touched("playerBall"))
isOver = true;
objects->handleAllFlags();
if(input->getKeyInput() == "r" || input->getMouseInput() == "Middle Down")
loadLevel();
camera.update();
}
void Level::draw()
{
objects->drawAll();
Ball* ball = (Ball*)(objects->getEntity("playerBall"));
ball->touched("Goal");
/*double magnitude = sqrt((ball->getXVel() * ball->getXVel()) + (ball->getYVel() * ball->getYVel()));
//Draw the text shawdow.
glColor3f(1.0,0.0,0.0);
resourceMgr->drawText("Arial", magnitude, window->leftCoord() + 100, window->topCoord() - 50);
*/
}
void Level::loadLevel()
{
if(!player)
player = new Player();
objects->loadLevel(levelFile);
Entity* ball = objects->getEntity("playerBall");
player->setPlayerBall((Ball*)(ball));
}
bool Level::levelWon()
{
return isOver;
}