game_in_work_example

This commit is contained in:
unknown
2010-08-31 19:25:29 +04:00
parent d4a9f33816
commit bbb6f9b366
14 changed files with 363 additions and 404 deletions

View File

@@ -11,7 +11,7 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
setAlignment(Qt::AlignLeft | Qt::AlignTop);
scene = new QGraphicsScene();
setScene(scene);
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
//setDragMode(RubberBandDrag);
//gsw = new QGraphicsWidget();
@@ -56,14 +56,14 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
pen.setColor(Qt::black);
brush.setColor(Qt::black);
}
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// }
// if (cel >= Map::PlayerAlien) {
// pen.setColor(Qt::yellow);
// brush.setColor(Qt::yellow);
// }
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// }
// if (cel >= Map::PlayerAlien) {
// pen.setColor(Qt::yellow);
// brush.setColor(Qt::yellow);
// }
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall))
{
pen.setColor(QColor(qAbs(cel)%255,(qAbs(cel)*100)%255,(qAbs(cel)+100)%255,50));
@@ -83,15 +83,21 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//p->translate(rec.width()/2, rec.height()/2);
//p->rotate(-90);
//p->translate(-rec.height()/2, -rec.width()/2);
//QBrush brush;
//brush.setColor(Qt::darkRed);
//brush.setStyle(Qt::DiagCrossPattern);
p->translate((*i).pos * cellSize+QPointF(20,20));
p->rotate((*i).angle);
//p->setPen(QColor(0,0,0,0));
//p->setBrush(brush);
//p->drawRect(QRect(-10,-10,20,20));
p->drawImage(QRect(-20,-20,40,40), images[itTowers][0]->at(0));
if ((*i).build < data->players.at((*i).PlayerId)->srcTowers.at((*i).src).buildTime)
{
QBrush brush;
brush.setColor(Qt::darkRed);
brush.setStyle(Qt::DiagCrossPattern);
p->setBrush(brush);
p->drawRect(-20,-20,40,40);
} else {
p->drawImage(QRect(-20,-20,40,40), images[itTowers][(*i).imgType]->at(0));
}
p->resetTransform();
}
//qDebug() << "a:" << data->curAliens.size();
@@ -120,12 +126,12 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//QBrush brush;
//brush.setColor(Qt::red);
//brush.setStyle(Qt::SolidPattern);
p->translate((*i).pos * cellSize+QPointF(10,10));
p->translate((*i).pos * cellSize);
p->rotate((*i).angle);
//p->setBrush(brush);
//p->setPen(QColor(0,0,0,0));
//p->drawEllipse(QPoint(),5,5);
p->drawImage(QRect(-10,-10,20,20), images[itSplashes][0]->at(0));
p->drawImage(QPoint(-(images[itSplashes][(*i).imgType]->at(0).size().width()/2),-(images[itSplashes][(*i).imgType]->at(0).size().height()/2)), images[itSplashes][(*i).imgType]->at(0));
p->resetTransform();
}
}
@@ -149,8 +155,12 @@ void AD_Graphics::loadImages()
break;
case itTowers:
images[i].push_back(new Animation(":/images/images/Towers/01_6.png"));
images[i].push_back(new Animation(":/images/images/Towers/00_0.png"));
case itSplashes:
images[i].push_back(new Animation(":/images/images/Splashes/Rocket.png"));
images[i].push_back(new Animation(":/images/images/Splashes/Shot_0.png"));
images[i].push_back(new Animation(":/images/images/Splashes/Smoke_01.png"));
images[i].push_back(new Animation(":/images/images/Splashes/expl.png"));
default: break;
}
}