Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Tetris_task.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
QT += core gui
QT += multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
tetrixboard.cpp \
tetrixpiece.cpp \
tetrixwindow.cpp

HEADERS += \
tetrixboard.h \
tetrixpiece.h \
tetrixwindow.h

FORMS +=

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DISTFILES += \
Video_Game_Players_-_Tetris_Theme_48152782.mp3
425 changes: 425 additions & 0 deletions Tetris_task.pro.user

Large diffs are not rendered by default.

Binary file added Video_Game_Players_-_Tetris_Theme_48152782.mp3
Binary file not shown.
32 changes: 22 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#include <QApplication>

#include "tetris.h"

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
Tetris w;
w.show();
return a.exec();
}
#include "tetrixwindow.h"

#include <QApplication>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QDir>
#include <QUrl>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TetrixWindow window;
window.show();
QMediaPlaylist *playlist = new QMediaPlaylist();
playlist->addMedia(QUrl("qrc:/tetris_music/background.wav"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
QMediaPlayer *player = new QMediaPlayer;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В отрыве можно подумать, что это какой-то игрок, уточните, что это все же mediaPlayer

player->setMedia(playlist);
player->setVolume(10);
player->play();
return app.exec();
}
14 changes: 14 additions & 0 deletions tetrisform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "tetrisform.h"
#include "ui_tetrisform.h"

tetrisForm::tetrisForm(QWidget *parent) :

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Названия классов с большой буквы

QWidget(parent),
ui(new Ui::tetrisForm)
{
ui->setupUi(this);
}

tetrisForm::~tetrisForm()
{
delete ui;
}
15 changes: 15 additions & 0 deletions tetrismainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "tetrismainwindow.h"
#include "ui_tetrismainwindow.h"

TetrisMainWindow::TetrisMainWindow(QWidget *parent)
: QWidget(parent)
, ui(new Ui::TetrisMainWindow)
{
ui->setupUi(this);
}

TetrisMainWindow::~TetrisMainWindow()
{
delete ui;
}

31 changes: 31 additions & 0 deletions tetrismainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef TETRISMAINWINDOW_H
#define TETRISMAINWINDOW_H

#include <QWidget>

QT_BEGIN_NAMESPACE
namespace Ui { class TetrisMainWindow; }
QT_END_NAMESPACE

class TetrisMainWindow : public QWidget
{
Q_OBJECT

public:
TetrisMainWindow(QWidget *parent = nullptr);
~TetrisMainWindow();

private:
Ui::TetrisMainWindow *ui;
QLabel *createLabel(const QString &text);

TetrisBoard *board;
QLabel *nextPieceLabel;
QLCDNumber *scoreLcd;
QLCDNumber *levelLcd;
QLCDNumber *linesLcd;
QPushButton *startButton;
QPushButton *quitButton;
QPushButton *pauseButton;
Comment on lines +22 to +29

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У полей с модификаторами доступа private и protected добавляем постфикс "_".

QPushButton *pauseButton -> QPushButton *pauseButton_ и т.д.

};
#endif // TETRISMAINWINDOW_H
19 changes: 19 additions & 0 deletions tetrismainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TetrisMainWindow</class>
<widget class="QWidget" name="TetrisMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>TetrisMainWindow</string>
</property>
</widget>
<resources/>
<connections/>
</ui>
Loading