fixed some bugs (clear path on map, ASCII game print;-)

This commit is contained in:
2010-07-30 01:56:37 +04:00
parent 5318650e91
commit 87455a622e
6 changed files with 21 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: aliendefender
# Generated by qmake (2.01a) (Qt 4.6.2) on: ?? ???? 29 09:41:29 2010
# Generated by qmake (2.01a) (Qt 4.6.2) on: ?? ???? 30 01:35:39 2010
# Project: aliendefender.pro
# Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro

View File

@@ -19,6 +19,8 @@ adCore::adCore(QObject *parent) :
adaliens->AddAlien(0);
for (int i=0; i<qMin(admap->mapsize.width(),admap->mapsize.height()); i++)
adtowers->AddTower(0,0,QPoint(i,i));
for (int i=0; i<admap->mapsize.height();i++)
adtowers->AddTower(1,0,QPoint(admap->mapsize.width()-2,i));
}

View File

@@ -36,6 +36,7 @@ void Aliens::AddAlien(int srcId)
void Aliens::retrace(bool *OK)
{
qDebug("retarce!");
gameData->map->removeAliensPath();
for (int i=0; i<gameData->curAliens.size(); i++)
{
Alien al = gameData->curAliens.at(i);
@@ -73,10 +74,10 @@ void Aliens::update()
for (int i=0; i<gameData->curAliens.size(); i++)
{
Alien al = gameData->curAliens.at(i);
qDebug() << i;
//qDebug() << i;
//if (al.health < 0) emit AlienKill();
float tmpdx,tmpdy,angl,arctg = 0;
qDebug() << "path index" << al.pathIndex;
qDebug() <<"alien"<< i << " path index" << al.pathIndex << " pos" << al.pos;
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*al.speed)

View File

@@ -1,3 +1,3 @@
cells path = example16x12.map
cells path = example16x16.map
max players = 2

15
map.cpp
View File

@@ -46,6 +46,17 @@ void Map::printMap()
}
void Map::removeAliensPath()
{
for (int i=0; i<Cells.size(); i++)
{
for (int j=0; j<Cells[i].size(); j++)
{
if (Cells[i][j] > 1000 && Cells[i][j] < 2000) Cells[i][j]=Cells[i][j]-1000;
}
}
}
bool Map::addTowerOnMap(int playerId, QPoint pos)
{
if (playerId < 0 || playerId > maxPlayers) return false;
@@ -237,8 +248,8 @@ int Map::WaveTrace(QPoint start, QPoint finish)
}
step++;
}
//qDebug() << "trace false";
qDebug() << TmpCells;
qDebug() << "trace false";
//qDebug() << TmpCells;
return -1;
}

1
map.h
View File

@@ -47,6 +47,7 @@ public:
int Id() const {return mapId;}
bool addTowerOnMap(int playerId, QPoint pos);
void delTowerOnMap(QPoint pos);
void removeAliensPath();
QVector <QPointF> CreatePath(QPoint start, QPoint finish);
QSize size() const {return mapsize;}
void ReadSettings();