added animation

but not full in ADeditor
This commit is contained in:
2010-09-05 16:25:23 +04:00
parent c898f978da
commit 8fa6b8e2a6
24 changed files with 924 additions and 725 deletions

View File

@@ -4,7 +4,6 @@
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
{
loadImages();
data = adcore->addata;
core = adcore;
//scale(cellSize, cellSize);
@@ -41,8 +40,8 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
// }
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
{
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,150));
brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,80));
}
p.setPen(pen);
p.setBrush(brush);
@@ -50,7 +49,7 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
}
}
startTimer(25);
startTimer(50);
show();
}
@@ -143,7 +142,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
p->setBrush(brush);
p->drawRect(-20,-20,40,40);
} else {
p->drawImage(QRect(-20,-20,40,40), images[itTowers][(*i).imgType]->at(0));
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
}
p->resetTransform();
}
@@ -158,7 +157,10 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//p->translate(-rec.height()/2, -rec.width()/2);
p->translate((*i).pos * cellSize+QPointF(10,10));
p->rotate((*i).angle);
p->drawImage(QRect(-20,-20,40,40), images[itAliens][0]->at(0));
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
(*i).animIndex++;
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
(*i).animIndex = 0;
p->resetTransform();
}
//qDebug() << "s:" << data->curSplashes.size();
@@ -178,7 +180,12 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//p->setBrush(brush);
//p->setPen(QColor(0,0,0,0));
//p->drawEllipse(QPoint(),5,5);
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));
QImage img;
img = *data->curAnimations.at((*i).imgType).images.at((*i).animIndex);
p->drawImage(QPoint(-(img.size().width()/2),-(img.size().height()/2)), img);
(*i).animIndex++;
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
(*i).animIndex = 0;
p->resetTransform();
}
}
@@ -190,25 +197,3 @@ void AD_Graphics::draw()
//resetCachedContent();
//repaint();
}
void AD_Graphics::loadImages()
{
images.resize(3);
for (int i = 0; i < images.size(); i++) {
switch ((imagesType)i) {
case itAliens:
images[i].push_back(new Animation(":/images/images/Aliens/Al_00_0.png"));
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;
}
}
}