資源簡介
原創c++代碼,qt打磚塊游戲,初學者可以學習
代碼片段和文件信息
#include?“ball.h“
Ball::Ball(?qreal?x?qreal?y?qreal?radius?QColor?ballColor?)
{
????dirX?=?1.5;
????dirY?=?-1.5;
????speed?=?2.0;
????
????shape?=?new?QRectF(?x?y?radius?radius?);
????color?=?ballColor;
}
Ball::~Ball()
{
????delete?shape;
}
void?Ball::setShape(?const?QRectF?&newShape?)
{
????shape->setRect(?newShape.left()?newShape.top()
????newShape.width()?newShape.height()?);
}
void?Ball::setDirX(?qreal?newDirX?)
{
????dirX?=?newDirX;
}
void?Ball::setDirY(?qreal?newDirY?)
{
????dirY?=?newDirY;
}
QRectF?Ball::getShape()?const
{
????return?QRectF(?shape->left()?shape->top()
??shape->width()?shape->height()?);
}
void?Ball::move()
{
????shape->setLeft(?shape->left()?-?dirX?);
????shape->setRight(?shape->right()?-?dirX?);
????shape->setTop(?shape->top()?+?dirY?);
????shape->setBottom(?shape->bottom()?+?dirY?);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-08-26?13:32??dazhuankuai\
?????文件?????????851??2014-08-25?16:38??dazhuankuai\ball.cpp
?????文件?????????480??2014-08-25?16:45??dazhuankuai\ball.h
?????文件?????????615??2014-04-05?12:58??dazhuankuai\brick.cpp
?????文件?????????408??2014-08-25?16:39??dazhuankuai\brick.h
?????文件?????????501??2014-08-23?20:21??dazhuankuai\dazhuankuai.pro
?????文件???????18262??2014-08-26?12:42??dazhuankuai\dazhuankuai.pro.user
?????文件?????????639??2014-08-26?13:30??dazhuankuai\dynamicBrick.cpp
?????文件?????????405??2014-08-23?20:15??dazhuankuai\dynamicbrick.h
?????文件?????????175??2014-08-23?00:18??dazhuankuai\main.cpp
?????文件????????5068??2014-08-26?13:32??dazhuankuai\widget.cpp
?????文件????????1091??2014-08-26?12:49??dazhuankuai\widget.h
?????文件??????????78??2014-08-23?00:36??dazhuankuai\客戶要求.txt
評論
共有 條評論