Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt at adding beginning of a keying invaders game; minimal functi…
…ons implemented
- Loading branch information
Showing
5 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,67 @@ | ||
#include "KeyInvaders.h" | ||
#include <QtGui/QMenu> | ||
|
||
KeyInvaders::KeyInvaders() | ||
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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,40 @@ | ||
#ifndef KEYINVADERS_H | ||
#define KEYINVADERS_H | ||
|
||
class KeyInvaders : public MorseMode | ||
#include "../MorseMode.h" | ||
#include "MGameMode.h" | ||
#include "HighScores.h" | ||
|
||
#include <QtCore/QList> | ||
#include <QtCore/QList> | ||
#include <QtCore/QTime> | ||
|
||
class KeyInvaders : public MorseMode, MGameMode | ||
{ | ||
public: | ||
KeyInvaders(); | ||
KeyInvaders(Morse *parent, Ui::MainWindow *main); | ||
|
||
public slots: | ||
void advanceFrame(); | ||
|
||
virtual void switchToMode(); | ||
virtual void modeMenus(); | ||
void setupWidgets(); | ||
|
||
// standard functions | ||
virtual QString helpText(); | ||
virtual QString name(); | ||
virtual QString icon(); | ||
virtual void gameOver(); | ||
|
||
public slots: | ||
virtual void handleKeyPress(QChar letterPressed); | ||
virtual void handleKeyRelease(QChar letterPressed); | ||
|
||
private: | ||
HighScores m_scores; | ||
int m_keyCount; | ||
QTime m_startTime; | ||
QList<int> m_keyedTimes; | ||
}; | ||
|
||
#endif // KEYINVADERS_H |