forked from imoital/CastleBlast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsScreen.cpp
More file actions
117 lines (97 loc) · 3.24 KB
/
SettingsScreen.cpp
File metadata and controls
117 lines (97 loc) · 3.24 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// SettingsScreen.cpp
// CastleBlast
//
// Created by Inês on 12/5/11.
// Copyright 2011 AVT. All rights reserved.
//
#include "SettingsScreen.h"
#include "Loader.h"
#include "FontsManager.h"
namespace CastleBlast {
SettingsScreen::SettingsScreen()
{
#ifdef __APPLE__
_settingsScreenImage = Loader::loadTexture("Images/SettingsScreen.png");
#else
_settingsScreenImage = Loader::loadTexture("..\\..\\src\\Images\\SettingsScreen.png");
#endif
_fontsManager = (FontsManager*)cg::Registry::instance()->get("FONTS_MANAGER");
_numPlayers = 2;
}
SettingsScreen::~SettingsScreen() {}
void SettingsScreen::init()
{
cg::tWindowInfo win = cg::Manager::instance()->getApp()->getWindowInfo();
_width = win.width;
_height = win.height;
}
void SettingsScreen::draw()
{
glBindTexture(GL_TEXTURE_2D, _settingsScreenImage);
glDisable(GL_DEPTH_TEST); // Disables Depth Testing
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,_width,0,_height,-1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glDisable(GL_LIGHTING);
glColor3d(1, 1, 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
{
glTexCoord2d(0, 0);
glVertex2d(0, 0);
glTexCoord2d(0, 1);
glVertex2d(0, _height);
glTexCoord2d(1, 1);
glVertex2d(_width, _height);
glTexCoord2d(1, 0);
glVertex2d(_width, 0);
}
glEnd();
glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST);
std::stringstream numPlayers;
numPlayers << _numPlayers;
_fontsManager->printFont(50, 300, 1.3, 0, 1, "How many players will be playing?");
_fontsManager->printFont(650, 300, 1.3, 0, 1, numPlayers.str());
}
void SettingsScreen::update(unsigned long elapsed_millis)
{
if (cg::KeyBuffer::instance()->isKeyDown('1'))
_numPlayers = 1;
if (cg::KeyBuffer::instance()->isKeyDown('2'))
_numPlayers = 2;
if (cg::KeyBuffer::instance()->isKeyDown('3'))
_numPlayers = 3;
if (cg::KeyBuffer::instance()->isKeyDown('4'))
_numPlayers = 4;
if (cg::KeyBuffer::instance()->isKeyDown('5'))
_numPlayers = 5;
if (cg::KeyBuffer::instance()->isKeyDown('6'))
_numPlayers = 6;
if (cg::KeyBuffer::instance()->isKeyDown('7'))
_numPlayers = 7;
if (cg::KeyBuffer::instance()->isKeyDown('8'))
_numPlayers = 8;
if (cg::KeyBuffer::instance()->isKeyDown('9'))
_numPlayers = 9;
}
int SettingsScreen::getNumPlayers()
{
return _numPlayers;
}
void SettingsScreen::onReshape(int width, int height)
{
_width = width;
_height = height;
}
}