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)
|
||||
m_spawnInterval = MIN_SPAWN_SPEED;
|
||||
deleteBall(ball);
|
||||
m_score++;
|
||||
|
||||
ui->label->setText("Score: " + QString::number(m_score));
|
||||
}
|
||||
|
||||
void MainWindow::onBallSpawn() {
|
||||
|
|
|
@ -39,6 +39,7 @@ class MainWindow : public QMainWindow {
|
|||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
private:
|
||||
int m_score;
|
||||
float m_spawnInterval;
|
||||
QTimer m_spawnTimer;
|
||||
Ui::MainWindow* ui;
|
||||
|
|
|
@ -13,7 +13,21 @@
|
|||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
|
Loading…
Add table
Reference in a new issue