91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.19MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-09-28
  • 語言: 其他
  • 標(biāo)簽: QT??C/C++??小游戲??

資源簡介

一個基于Qt5的俄羅斯方塊游戲,包括背景圖片,背景音樂,方塊消除效果,方塊圖片效果。可以直接運(yùn)行。

資源截圖

代碼片段和文件信息

#include“box.h“
#include
#include
#include
#include
#include“sender.h“
#include
#include

OneBox::OneBox(const?QColor?&color):brushColor(color)
{
}
QRectF?OneBox::boundingRect()?const
{
????qreal?penWidth?=?1;
????return?QRectF(-10-penWidth/2-10-penWidth/220+penWidth20+penWidth);
}
void?OneBox::paint(QPainter?*painterconst?QstyleOptionGraphicsItem?*optionQWidget?*widget)
{
????//為小方塊使用貼圖
????painter->drawPixmap(-10-102020QPixmap(“:/images/box.gif“));
????painter->setBrush(brushColor);
????QColor?penColor?=?brushColor;
????//將顏色的透明度減小
????penColor.setAlpha(20);
????painter->setPen(penColor);
????painter->drawRect(-10-102020);
}
//形狀比邊框小0.5像素,這樣方塊組中的小方塊才不會發(fā)生碰撞
QPainterPath?OneBox::shape()?const
{
????QPainterPath?path;
????path.addRect(-9.5-9.51919);
????return?path;
}
BoxGroup::BoxGroup()
{
????setFlags(QGraphicsItem::ItemIsFocusable);
????//保存變換矩陣,當(dāng)BoxGroup進(jìn)行旋轉(zhuǎn)后,可以使用它來進(jìn)行恢復(fù)
????oldTransform?=?transform();
????timer?=?new?QTimer(this);
????nettimer?=?new?QTimer(this);
????connect(timerSIGNAL(timeout())thisSLOT(moveOneStep()));
????connect(nettimerSIGNAL(timeout())thisSLOT(netmoveOneStep()));
????currentShape=RandomShape;
????sender?=?new?Sender;
????connect(thisSIGNAL(lansend(QByteArray))senderSLOT(startBroadcasting(QByteArray)));
}
QRectF?BoxGroup::boundingRect()?const
{
????qreal?penWidth?=?1;
????return?QRectF(-40-penWidth/2-40-penWidth/2
??????????????????80+penWidth80+penWidth);
}
void?BoxGroup::keyPressEvent(QKeyEvent?*event)
{
????static?qreal?angle?=?0;
????switch(event->key())
????{
????case?Qt::Key_Down:
????????moveBy(020);
????????if(isColliding()){
????????????moveBy(0-20);
????????????//將小方塊從方塊組中移除到場景中
????????????clearBoxGroup();
????????????//需要顯示新的方塊
????????????emit?needNewBox(0);
????????}
????????emit?lansend(“1“);
????????qDebug(“down“);
????????break;
????case?Qt::Key_Left:
????????moveBy(-200);
????????if(isColliding())
????????????moveBy(200);
????????emit?lansend(“2“);
????????break;
????case?Qt::Key_Right:
????????moveBy(200);
????????if(isColliding())
????????????moveBy(-200);
????????emit?lansend(“3“);
????????break;
????case?Qt::Key_Up:
????????setRotation(angle+90.0);
????????angle?=?angle+90.0;
????????if(isColliding())
????????{
????????????setRotation(angle-90.0);
????????????angle?=?angle-90.0;
????????}
????????emit?lansend(“4“);
????????break;
????????//空格實現(xiàn)墜落
????case?Qt::Key_Space:
????????moveBy(020);
????????while(!isColliding()){
????????????moveBy(020);
????????}
????????moveBy(0-20);
????????clearBoxGroup();
????????emit?needNewBox(0);
????????emit?lansend(“5“);
????????break;
????}
}
void?BoxGroup::netevent(QByteArray?datagram)
{
????static?qreal?angle?=?0;
????QString?ch;
????int?a;
????ch=QString(datagram);
????a=ch.toInt();
????switch(a)
????{
????case?1:
????????moveBy(020);
????????if(isCol

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-24?22:54??Tetris\
?????文件?????????804??2018-07-11?15:22??Tetris\.gitignore
?????文件????????7868??2018-07-24?18:07??Tetris\box.cpp
?????文件????????1544??2018-07-24?18:07??Tetris\box.h
?????目錄???????????0??2018-07-11?17:23??Tetris\images\
?????文件?????????310??2018-07-11?17:25??Tetris\images.qrc
?????文件??????912897??2011-07-17?16:29??Tetris\images\background.png
?????文件??????709509??2011-07-17?13:39??Tetris\images\background01.png
?????文件??????645354??2011-07-17?13:51??Tetris\images\background02.png
?????文件????????1213??2011-07-17?11:41??Tetris\images\box.gif
?????文件????????1116??2011-07-17?11:13??Tetris\images\icon.png
?????文件????????7521??2011-03-17?17:09??Tetris\images\logo.png
?????文件?????????284??2018-07-11?22:14??Tetris\main.cpp
?????文件????????1030??2018-07-24?22:28??Tetris\sender.cpp
?????文件?????????551??2018-07-24?15:48??Tetris\sender.h
?????文件?????????127??2018-07-11?15:34??Tetris\tetris.h.autosave
?????文件?????????385??2018-07-23?23:14??Tetris\Tetris.pro
?????文件???????18439??2018-07-24?22:24??Tetris\Tetris.pro.user
?????文件???????21202??2018-07-24?22:54??Tetris\view.cpp
?????文件????????1898??2018-07-24?22:41??Tetris\view.h

評論

共有 條評論