adding alien class, but not work yet

This commit is contained in:
andrey
2010-02-05 08:02:08 +03:00
parent 4ad7d83625
commit 4c81b32bd3
4 changed files with 225 additions and 251 deletions

View File

@@ -1,11 +1,13 @@
#include "alien.h"
#include <cmath>
Alien::Alien()
{
}
bool Alien::CreatePath()
bool Alien::RecreatePath()
{
for (int i = 0; i < data->size.width(); i++)
{
@@ -55,7 +57,23 @@ bool Alien::CreatePath()
void Alien::update()
{
float tmpdx,tmpdy,arctg,tmpdx1,tmpdy1;
arctg = 0;
tmpdx = position->pnt.x() - path[PathIndex].x()*data->cellsize;
tmpdy = position->pnt.y() - path[PathIndex].y()*data->cellsize;
if (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < Speed*data->cellsize) PathIndex++;
if (PathIndex >= path.size()) PathIndex = path.size()-1;
tmpdx = position->pnt.x() - path[PathIndex].x()*cellsize;
tmpdy = position->pnt.y() - path[PathIndex].y()*cellsize;
arctg = std::atan(tmpdx/tmpdy);
Position.angle = 180.0f*(-arctg)/3.1416f;
if (tmpdy < 0) Position.angle = 180.0f + Position.angle;
Position.pnt.setX(Position.pnt.x()
+Speed*data->cellsize*std::sin(Position.angle));
Position.pnt.setY(Position.pnt.y()
-Speed*data->cellsize*std::cos(Position.angle));
PicIndex++;
if (PicIndex >= AlienPix.size()) PicIndex = 0;
}
@@ -130,6 +148,7 @@ QVector<QPoint> Alien::InvWaveTrace(QPoint finish, int cnt)
{
QPoint wp, Ppnt;
QVector<QPoint> alpath;
if (cnt < 2) return alpath;
int Ind, c, xpp, ypp, xnn, ynn;
unsigned char chk;
Ppnt = wp = finish;