fixed some bugs (clear path on map, ASCII game print;-)
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
# Makefile for building: aliendefender
|
# 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
|
# Project: aliendefender.pro
|
||||||
# Template: app
|
# Template: app
|
||||||
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro
|
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ adCore::adCore(QObject *parent) :
|
|||||||
adaliens->AddAlien(0);
|
adaliens->AddAlien(0);
|
||||||
for (int i=0; i<qMin(admap->mapsize.width(),admap->mapsize.height()); i++)
|
for (int i=0; i<qMin(admap->mapsize.width(),admap->mapsize.height()); i++)
|
||||||
adtowers->AddTower(0,0,QPoint(i,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ void Aliens::AddAlien(int srcId)
|
|||||||
void Aliens::retrace(bool *OK)
|
void Aliens::retrace(bool *OK)
|
||||||
{
|
{
|
||||||
qDebug("retarce!");
|
qDebug("retarce!");
|
||||||
|
gameData->map->removeAliensPath();
|
||||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||||
{
|
{
|
||||||
Alien al = gameData->curAliens.at(i);
|
Alien al = gameData->curAliens.at(i);
|
||||||
@@ -73,10 +74,10 @@ void Aliens::update()
|
|||||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||||
{
|
{
|
||||||
Alien al = gameData->curAliens.at(i);
|
Alien al = gameData->curAliens.at(i);
|
||||||
qDebug() << i;
|
//qDebug() << i;
|
||||||
//if (al.health < 0) emit AlienKill();
|
//if (al.health < 0) emit AlienKill();
|
||||||
float tmpdx,tmpdy,angl,arctg = 0;
|
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();
|
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
|
||||||
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
||||||
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*al.speed)
|
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*al.speed)
|
||||||
|
|||||||
2
map.conf
2
map.conf
@@ -1,3 +1,3 @@
|
|||||||
cells path = example16x12.map
|
cells path = example16x16.map
|
||||||
max players = 2
|
max players = 2
|
||||||
|
|
||||||
|
|||||||
15
map.cpp
15
map.cpp
@@ -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)
|
bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||||
{
|
{
|
||||||
if (playerId < 0 || playerId > maxPlayers) return false;
|
if (playerId < 0 || playerId > maxPlayers) return false;
|
||||||
@@ -237,8 +248,8 @@ int Map::WaveTrace(QPoint start, QPoint finish)
|
|||||||
}
|
}
|
||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
//qDebug() << "trace false";
|
qDebug() << "trace false";
|
||||||
qDebug() << TmpCells;
|
//qDebug() << TmpCells;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
map.h
1
map.h
@@ -47,6 +47,7 @@ public:
|
|||||||
int Id() const {return mapId;}
|
int Id() const {return mapId;}
|
||||||
bool addTowerOnMap(int playerId, QPoint pos);
|
bool addTowerOnMap(int playerId, QPoint pos);
|
||||||
void delTowerOnMap(QPoint pos);
|
void delTowerOnMap(QPoint pos);
|
||||||
|
void removeAliensPath();
|
||||||
QVector <QPointF> CreatePath(QPoint start, QPoint finish);
|
QVector <QPointF> CreatePath(QPoint start, QPoint finish);
|
||||||
QSize size() const {return mapsize;}
|
QSize size() const {return mapsize;}
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user