second test
This commit is contained in:
@@ -60,8 +60,10 @@ void adpainter::drawgrid()
|
||||
void adpainter::drawAliens(deque<QPointF> path, FPVector * position)
|
||||
{
|
||||
float tmpdx,tmpdy,arctg,tmpdx1,tmpdy1;
|
||||
//unsigned char dd[4];
|
||||
//int gg;
|
||||
arctg = 0;
|
||||
QTransform rotated;
|
||||
//QTransform rotated;
|
||||
painter.begin(buff);
|
||||
pen->setColor(QColor::fromRgb(qRgb(80,200,100)));
|
||||
brush->setColor(QColor::fromRgb(qRgb(230,10,10)));
|
||||
@@ -74,35 +76,50 @@ void adpainter::drawAliens(deque<QPointF> path, FPVector * position)
|
||||
}
|
||||
tmpdx = position->pnt.x() - path.at(StepAlien).x()*cellsize;
|
||||
tmpdy = position->pnt.y() - path.at(StepAlien).y()*cellsize;
|
||||
tmpdx1 = position->pnt.x() - path.at(StepAlien+1).x()*cellsize;
|
||||
tmpdy1 = position->pnt.y() - path.at(StepAlien+1).y()*cellsize;
|
||||
/*if (qAbs(tmpdy1) > 0.01 && qAbs(tmpdx1) > 0.01)*/ arctg = atan(tmpdx1/tmpdy1);
|
||||
if (StepAlien + 2 < path.size()) {
|
||||
tmpdx1 = position->pnt.x() - path.at(StepAlien+2).x()*cellsize;
|
||||
tmpdy1 = position->pnt.y() - path.at(StepAlien+2).y()*cellsize;
|
||||
}
|
||||
arctg = atanf(tmpdx1/tmpdy1);
|
||||
//memcpy(&gg,&arctg,4);
|
||||
if (tmpdy1 != 0) position->angle = 180*(-arctg)/3.1415;
|
||||
if (AlienPix.size() > 0) {
|
||||
//painter.rotate((arctg/3.1415)*180);
|
||||
rotated.rotateRadians(arctg/* + 3.1415/2*/);
|
||||
qDebug() << "angle:" << arctg;
|
||||
painter.save();
|
||||
painter.translate(position->pnt.x()+cellsize,position->pnt.y()+cellsize);
|
||||
//if (arctg == 0) painter.rotate(90);
|
||||
position->angle = 180*(-arctg)/3.1415;
|
||||
painter.rotate(position->angle);
|
||||
//position->pnt.setX(path.at(0).x());
|
||||
//position->pnt.setY(path.at(0).y());
|
||||
painter.drawPixmap(0, 0, cellsize*2, cellsize*2, AlienPix.at(AnimAlien));
|
||||
AnimAlien++;
|
||||
painter.restore();
|
||||
rotated.reset();
|
||||
//rotated.rotateRadians(arctg/* + 3.1415/2*/);
|
||||
//qDebug() << "angle:" << arctg;
|
||||
//rotated.reset();
|
||||
if (qAbs(tmpdx) < 1 && qAbs(tmpdy) < 1) StepAlien++;
|
||||
else {
|
||||
if (qAbs(tmpdx) <= qAbs(tmpdy)) {
|
||||
if (tmpdy < 0) position->pnt.ry()++;
|
||||
else position->pnt.ry()--;
|
||||
if (tmpdy < 0) {
|
||||
position->pnt.ry()++;
|
||||
//position->angle = - position->angle;
|
||||
}
|
||||
else {
|
||||
position->pnt.ry()--;
|
||||
}
|
||||
}
|
||||
if (qAbs(tmpdx) >= qAbs(tmpdy)) {
|
||||
if (tmpdx < 0) position->pnt.rx()++;
|
||||
if (tmpdx < 0) {
|
||||
position->pnt.rx()++;
|
||||
//position->angle = - position->angle;
|
||||
}
|
||||
else position->pnt.rx()--;
|
||||
}
|
||||
}
|
||||
//painter.save();
|
||||
painter.translate(position->pnt.x()-cellsize,position->pnt.y()-cellsize);
|
||||
//if (arctg == 0) painter.rotate(90);
|
||||
//memcpy(dd,&gg,4);
|
||||
//dd[0]=0xFF;
|
||||
qDebug() << "angle:" << position->angle;
|
||||
//qDebug() << dd[0] << dd[1] << dd[2] << dd[3];
|
||||
painter.rotate(position->angle);
|
||||
//position->pnt.setX(path.at(0).x());
|
||||
//position->pnt.setY(path.at(0).y());
|
||||
painter.drawPixmap(cellsize/2, cellsize/2, cellsize*2, cellsize*2, AlienPix.at(AnimAlien));
|
||||
AnimAlien++;
|
||||
//painter.restore();
|
||||
if (AnimAlien >= AlienPix.size()) AnimAlien = 0;
|
||||
if (StepAlien >= path.size()) StepAlien = 0;
|
||||
//qDebug() << StepAlien;
|
||||
|
||||
Reference in New Issue
Block a user