-
Notifications
You must be signed in to change notification settings - Fork 8
/
KeyInvaders.cpp
67 lines (52 loc) · 1.36 KB
/
KeyInvaders.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
63
64
65
66
67
#include "KeyInvaders.h"
#include <QtGui/QMenu>
KeyInvaders::KeyInvaders(Morse *parent, Ui::MainWindow *main)
: MorseMode(parent, main), m_scores("Key Invaders")
{
}
void
KeyInvaders::advanceFrame() {
}
void KeyInvaders::switchToMode() {
m_ui->helpBar->setText(tr("<font color=\"green\">Key the letters using a st.</font>"));
m_ui->changeSequence->hide();
setupWidgets();
}
void KeyInvaders::modeMenus() {
// Create the high scores button
QAction *action = menu()->addAction("HighScores");
connect(action, SIGNAL(triggered()), &m_scores, SLOT(showScores()));
}
void KeyInvaders::setupWidgets() {
}
void KeyInvaders::handleKeyPress(QChar letterPressed)
{
Q_UNUSED(letterPressed);
// memorize keypress timing
if (m_keyCount == 0) {
m_startTime.start();
m_keyedTimes.push_back(0);
} else {
m_keyedTimes.push_back(m_startTime.elapsed());
}
}
void KeyInvaders::handleKeyRelease(QChar letterPressed)
{
handleKeyPress(letterPressed); // doesn't really matter whether it's up/down
}
void KeyInvaders::gameOver()
{
m_scores.addScore("", score());
}
QString KeyInvaders::helpText()
{
return tr("<p>Shoot letters falling from the sky by keying them appropriately.</p>");
}
QString KeyInvaders::name()
{
return tr("Key Invaders");
}
QString KeyInvaders::icon()
{
return ":/icons/64x64/game.png";
}