#include "Item.h"
QFishItem::QFishItem(char acFileName[30], QGraphicsItem *parent):QGraphicsItem(parent)
{
strcpy(this->acFileName, acFileName);
x1 = 0;
y1 = 100;
}
QRectF QFishItem::boundingRect() const//绘制Item大概的区域
{
return QRectF(-58, -26, 115, 51);
}
//绘制Item的内容
void QFishItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
static int i = 1;
char acFileName[30] = "";
painter->drawRect(-58, -26, 115, 51);
sprintf(acFileName, "./swimming/shark_r%d.png", i);
painter->drawPixmap(-58, -26, 115, 51, QPixmap(acFileName));
i++;
if(i == 5)
{
i = 1;
}
}
void QFishItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
qDebug("mouse press.\n");
}
void QFishItem::advance(int phase)
{
qreal angle = 90;
qreal dx = sin(angle) * 5;
x1 += dx;
if(x1 == 800)
{
x1 = 0;
}
setPos(x1+70, 200);
}
QRectF QGunItem::boundingRect()const
{
return QRectF(-33, -44, 66, 88);
}
void QGunItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->drawPixmap(-33, -44, 66, 88, QPixmap("pao5.png"));
}
QBulletItem::QBulletItem(qreal angle, QGraphicsItem *parent):QGraphicsItem(parent)
{
this->angle = 90 - angle;
setPos(430, 440);
setRotation(this->angle);
}
QRectF QBulletItem::boundingRect() const
{
return QRectF(-9, -20, 18, 39);
}
void QBulletItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QNetItem *pNet;
painter->drawPixmap(-9, -20, 18, 39, QPixmap("B5.png"));
if(!(this->scene()->collidingItems(this).isEmpty()))
{
qDebug("2014...\n");
QList <QGraphicsItem *> hits = this->scene()->collidingItems(this);
QList <QGraphicsItem *>::Iterator it;
for(it = hits.begin(); it != hits.end(); it++)
{
painter->drawPixmap(-43, -39, 86, 78, QPixmap("net.png"));
qDebug("2014colliding...\n");
}
}
}
void QBulletItem::advance(int phase)
{
qreal dx;
qreal dy;
double rad;//弧度
rad = angle * PI / 180;
dx = ::sin(rad) * 10;//sin函数里的参数是弧度表示的
dy = dx / ::tan(rad);
moveBy(dx, -dy);
}
QPainterPath QBulletItem::shape() const
{
QPainterPath Path;
Path.addRect(-9, -20, 18, 39);
return Path;
}
bool QBulletItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const
{
qDebug("collidesWithItem.......\n");
}
QNetItem::QNetItem(QGraphicsItem *parent):QGraphicsItem(parent)
{
}
QRectF QNetItem::boundingRect() const
{
return QRectF(-43, -39, 86, 78);
}
void QNetItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->drawPixmap(-43, -39, 86, 78, QPixmap("net1.png"));
}
没有合适的资源?快使用搜索试试~ 我知道了~
捕鱼达人游戏代码
共135个文件
png:55个
o:28个
cpp:24个
5星 · 超过95%的资源 需积分: 36 55 下载量 172 浏览量
2014-09-10
16:32:05
上传
评论 1
收藏 10.79MB RAR 举报
温馨提示
用QT实现的捕鱼达人游戏,基本功能实现,使用QT代码实现
资源推荐
资源详情
资源评论
收起资源包目录
捕鱼达人游戏代码 (135个子文件)
Item.cpp 3KB
View.cpp 3KB
moc_GameWidget.cpp 2KB
moc_FishWidget.cpp 2KB
FishWidget.cpp 2KB
moc_xiaohuanyu.cpp 2KB
moc_xiaochouyu.cpp 2KB
moc_xiaolvyu.cpp 2KB
moc_fishitem.cpp 2KB
moc_lvyu_1.cpp 2KB
moc_lvyu.cpp 2KB
moc_yuan.cpp 2KB
GameWidget.cpp 2KB
bullet.cpp 2KB
fishitem.cpp 953B
xiaohuanyu.cpp 920B
xiaochouyu.cpp 914B
xiaolvyu.cpp 899B
lvyu.cpp 870B
yuan.cpp 781B
pixmapitem.cpp 510B
main.cpp 398B
gun.cpp 324B
net.cpp 205B
Makefile.Debug 14KB
Makefile.Debug 5KB
object_script.Fishing.Debug 482B
Fishing.exe 7.23MB
Fishing.exe 1.15MB
Item.h 2KB
View.h 722B
pixmapitem.h 455B
GameWidget.h 451B
FishWidget.h 411B
xiaohuanyu.h 359B
xiaochouyu.h 357B
xiaolvyu.h 349B
fishitem.h 341B
lvyu.h 333B
yuan.h 331B
bullet.h 322B
gun.h 286B
net.h 215B
Flour.jpg 16KB
Makefile 6KB
Makefile 5KB
Item.o 430KB
Item.o 389KB
pixmapitem.o 385KB
xiaohuanyu.o 384KB
xiaochouyu.o 384KB
xiaolvyu.o 384KB
moc_xiaochouyu.o 384KB
moc_xiaohuanyu.o 384KB
fishitem.o 384KB
moc_xiaolvyu.o 384KB
yuan.o 384KB
moc_lvyu_1.o 383KB
moc_lvyu.o 383KB
moc_yuan.o 383KB
moc_fishitem.o 383KB
lvyu.o 383KB
gun.o 382KB
FishWidget.o 328KB
GameWidget.o 327KB
View.o 288KB
Qbullet.o 268KB
bullet.o 268KB
View.o 266KB
moc_FishWidget.o 256KB
moc_GameWidget.o 256KB
main.o 250KB
main.o 237KB
net.o 235KB
beijin.png 1.11MB
beijin.png 1.11MB
aboutus.png 1.08MB
seaworld.png 734KB
Batfish_3.png 70KB
Batfish_2.png 68KB
Batfish_4.png 65KB
Batfish_5.png 56KB
Batfish_1.png 50KB
logo.png 44KB
shark_2.png 38KB
shark_5.png 37KB
shark_1.png 37KB
shark_4.png 36KB
shark_3.png 33KB
start.png 26KB
set.png 23KB
medusa_5.png 22KB
medusa_2.png 22KB
medusa_1.png 22KB
help.png 16KB
easy.png 15KB
hard.png 15KB
normal.png 15KB
back.png 15KB
medusa_4.png 15KB
共 135 条
- 1
- 2
资源评论
- Cyrus_Br2014-12-24看这效果不错,代码还没有细看..就来评分
- TIANQIBUCUO_h2014-11-27还不错,基本上是动画!虽然很多功能未实现,但也值得参考
- mxdhqm2016-11-25这效果不错,代码还没有细看..就来评分
- FireBirdCN2021-01-19帮朋友下载的,反馈说有一定价值
money_metal
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功