Add score
This commit is contained in:
parent
14da8dce44
commit
24eeaa411b
3 changed files with 19 additions and 1 deletions
|
@ -68,6 +68,9 @@ void MainWindow::ballCaught(Ball* ball) {
|
||||||
if (m_spawnInterval < MIN_SPAWN_SPEED)
|
if (m_spawnInterval < MIN_SPAWN_SPEED)
|
||||||
m_spawnInterval = MIN_SPAWN_SPEED;
|
m_spawnInterval = MIN_SPAWN_SPEED;
|
||||||
deleteBall(ball);
|
deleteBall(ball);
|
||||||
|
m_score++;
|
||||||
|
|
||||||
|
ui->label->setText("Score: " + QString::number(m_score));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onBallSpawn() {
|
void MainWindow::onBallSpawn() {
|
||||||
|
|
|
@ -39,6 +39,7 @@ class MainWindow : public QMainWindow {
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_score;
|
||||||
float m_spawnInterval;
|
float m_spawnInterval;
|
||||||
QTimer m_spawnTimer;
|
QTimer m_spawnTimer;
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
|
@ -13,7 +13,21 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Score: 0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue