forked from imoital/CastleBlast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenManager.cpp
More file actions
67 lines (58 loc) · 1.55 KB
/
ScreenManager.cpp
File metadata and controls
67 lines (58 loc) · 1.55 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
//
// ScreenManager.cpp
// CastleBlast
//
// Created by Inês on 12/5/11.
// Copyright 2011 AVT. All rights reserved.
//
#include "ScreenManager.h"
#include "StartScreen.h"
#include "SettingsScreen.h"
#include "GameManager.h"
namespace CastleBlast {
ScreenManager::ScreenManager() : cg::Entity("SCREEN_MANAGER") {}
ScreenManager::~ScreenManager() {}
void ScreenManager::init()
{
_startScreen = new StartScreen();
_settingScreen = new SettingsScreen();
_isStartScreen = true;
}
void ScreenManager::draw()
{
if (_isStartScreen)
_startScreen->draw();
else _settingScreen->draw();
}
void ScreenManager::update(unsigned long elapsed_millis)
{
if (_isStartScreen)
_startScreen->update(elapsed_millis);
else _settingScreen->update(elapsed_millis);
}
void ScreenManager::onMouse(int button, int state, int x, int y)
{
GameManager *gameManager = (GameManager*)cg::Registry::instance()->get("GAME_MANAGER");
if (_isStartScreen) {
if(x >= 265 && x <= 555 && y >= 270 && y <= 330)
gameManager->startGame(2);
if(x >= 265 && x <= 555 && y >= 384 && y <= 444)
_isStartScreen = false;
}
else {
std::cout << "" << x << " " << y << std::endl;
if (x >= 72 && x <= 357 && y >= 485 && y <= 545) {
_isStartScreen = true;
}
if (x >= 440 && x <= 725 && y >= 485 && y <= 545) {
_isStartScreen = true;
gameManager->startGame(_settingScreen->getNumPlayers());
}
}
}
void ScreenManager::onReshape(int width, int height)
{
_startScreen->onReshape(width, height);
_settingScreen->onReshape(width, height);
}
}