diff --git a/ad_graphics.cpp b/ad_graphics.cpp index c0c6821..fa99cc3 100644 --- a/ad_graphics.cpp +++ b/ad_graphics.cpp @@ -72,6 +72,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & ) p->drawRect(i*cellSize,j*cellSize,cellSize,cellSize); } } + qDebug() << "t:" << data->curTowers.size(); for (QHash::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i) { //qDebug() << "draw alien"; //p->rotate(-90); @@ -80,7 +81,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & ) //p->rotate(-90); //p->translate(-rec.height()/2, -rec.width()/2); QBrush brush; - brush.setColor(Qt::darkGreen); + brush.setColor(Qt::darkRed); brush.setStyle(Qt::DiagCrossPattern); p->translate((*i).pos * cellSize+QPointF(10,10)); p->rotate((*i).angle); @@ -89,6 +90,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & ) p->drawRect(QRect(-10,-10,20,20)); p->resetTransform(); } + qDebug() << "a:" << data->curAliens.size(); for (QHash::iterator i = data->curAliens.begin(); i != data->curAliens.end(); ++i) { //qDebug() << "draw alien"; //p->rotate(-90); @@ -101,6 +103,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & ) p->drawImage(QRect(-20,-20,40,40), images[itAliens][0]->at(0)); p->resetTransform(); } + qDebug() << "s:" << data->curSplashes.size(); for (QHash::iterator i = data->curSplashes.begin(); i != data->curSplashes.end(); ++i) { //qDebug() << "draw alien"; //p->rotate(-90); diff --git a/aliendefender.pro.user b/aliendefender.pro.user index 7122a0f..be6236a 100644 --- a/aliendefender.pro.user +++ b/aliendefender.pro.user @@ -1,113 +1,241 @@ - ProjectExplorer.Project.ActiveTarget + RunConfiguration0-BaseEnvironmentBase + 2 + + + RunConfiguration0-CommandLineArguments + + + + RunConfiguration0-ProFile + aliendefender.pro + + + RunConfiguration0-RunConfiguration.name + aliendefender + + + RunConfiguration0-UseDyldImageSuffix + false + + + RunConfiguration0-UseTerminal + false + + + RunConfiguration0-UserEnvironmentChanges + + + + RunConfiguration0-UserSetName + false + + + RunConfiguration0-UserSetWorkingDirectory + false + + + RunConfiguration0-UserWorkingDirectory + + + + RunConfiguration0-type + Qt4ProjectManager.Qt4RunConfiguration + + + activeRunConfiguration 0 - ProjectExplorer.Project.EditorSettings + activebuildconfiguration + Debug + + + buildConfiguration-Debug - System + Debug + 0 + 0 + 2 - ProjectExplorer.Project.Target.0 + buildConfiguration-Release - Настольный компьютер - Qt4ProjectManager.Target.DesktopTarget - 0 - 0 - - - qmake - QtProjectManager.QMakeBuildStep - - - - Сборка - Qt4ProjectManager.MakeStep - false - - - - 2 - - Сборка - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Отладка - Qt4ProjectManager.Qt4BuildConfiguration - 2 - C:/Users/Andrey/Desktop/build-AD - 9 - 2 - true - - - - qmake - QtProjectManager.QMakeBuildStep - - - - Сборка - Qt4ProjectManager.MakeStep - false - - - - 2 - - Сборка - Qt4ProjectManager.MakeStep - true - - clean - - - - 1 - false - - Релиз - Qt4ProjectManager.Qt4BuildConfiguration - 0 - C:/Users/Andrey/Desktop/aliendefender-build-desktop - 9 - 2 - true - - 2 - - aliendefender - Qt4ProjectManager.Qt4RunConfiguration - 2 - - aliendefender.pro - false - false - - false - true - C:\Users\Andrey\Desktop\aliendefender - - 1 + Release + 0 + 0 - ProjectExplorer.Project.TargetCount - 1 + buildconfiguration-Debug-buildstep0 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822 + DEFAULTS_PATH=/usr/share/gconf/gnome.default.path + DESKTOP_SESSION=gnome + DISPLAY=:0.0 + GDMSESSION=gnome + GDM_KEYBOARD_LAYOUT=us + GDM_LANG=ru_RU.UTF-8 + GNOME_DESKTOP_SESSION_ID=this-is-deprecated + GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf + GTK_MODULES=canberra-gtk-module + HOME=/home/andrey + LANG=ru_RU.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LOGNAME=andrey + MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path + ORBIT_SOCKETDIR=/tmp/orbit-andrey + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + PWD=/home/andrey + QTDIR=/usr/share/qt4 + SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 + SHELL=/bin/bash + SPEECHD_PORT=6561 + SSH_AGENT_PID=1239 + SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh + USER=andrey + USERNAME=andrey + XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database + XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg + XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ + XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279 + + + /home/andrey/AD/aliendefender/aliendefender.pro + -spec + linux-g++ + -r + CONFIG+=debug + + /usr/bin/qmake-qt4 + false + /home/andrey/AD/aliendefender + - ProjectExplorer.Project.Updater.FileVersion - 4 + buildconfiguration-Debug-buildstep1 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822 + DEFAULTS_PATH=/usr/share/gconf/gnome.default.path + DESKTOP_SESSION=gnome + DISPLAY=:0.0 + GDMSESSION=gnome + GDM_KEYBOARD_LAYOUT=us + GDM_LANG=ru_RU.UTF-8 + GNOME_DESKTOP_SESSION_ID=this-is-deprecated + GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf + GTK_MODULES=canberra-gtk-module + HOME=/home/andrey + LANG=ru_RU.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LOGNAME=andrey + MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path + ORBIT_SOCKETDIR=/tmp/orbit-andrey + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + PWD=/home/andrey + QTDIR=/usr/share/qt4 + SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 + SHELL=/bin/bash + SPEECHD_PORT=6561 + SSH_AGENT_PID=1239 + SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh + USER=andrey + USERNAME=andrey + XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database + XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg + XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ + XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279 + + false + + -w + + /usr/bin/make + true + /home/andrey/AD/aliendefender + + + + buildconfiguration-Debug-cleanstep0 + + Debug + true + + clean + + + + + buildconfiguration-Release-buildstep0 + + Release + + + + buildconfiguration-Release-buildstep1 + + Release + + + + buildconfiguration-Release-cleanstep0 + + Release + + + + buildconfigurations + + Debug + Release + + + + buildstep0 + + + + + + + buildstep1 + + + + + + buildsteps + + trolltech.qt4projectmanager.qmake + trolltech.qt4projectmanager.make + + + + cleanstep0 + + + true + + + + cleansteps + + trolltech.qt4projectmanager.make + + + + defaultFileEncoding + System + + + project + diff --git a/data2.xml b/data2.xml index 5da65d6..7806e97 100644 --- a/data2.xml +++ b/data2.xml @@ -2,9 +2,9 @@ - - - + + + @@ -12,11 +12,11 @@ - - - - - + + + + + @@ -28,7 +28,7 @@ - + @@ -60,16 +60,16 @@ - + - + - - - + + + diff --git a/splashes.cpp b/splashes.cpp index ab87820..07a9667 100644 --- a/splashes.cpp +++ b/splashes.cpp @@ -58,7 +58,7 @@ void Splashes::addSplash(srcSplashType src, int index, TowerType tw) spl.AlienId = tw.aim; else spl.AlienId = -1; - spl.angle = tw.angle; + spl.angle = tw.angle; // FIXME: tower not rotate spl.pos = tw.pos; // FIXME: pos not in center or left-angle of tower spl.imgType = src.imgType; spl.life = 0; @@ -80,7 +80,7 @@ void Splashes::update() QList deadIndexes; for (int i=0; icurSplashes.size(); i++) { - int curDead = -1; + //int curDead = -1; float arctg,angl; SplashType spl = gameData->curSplashes.values().at(i); //bool isTowerSplash = false; @@ -90,46 +90,39 @@ void Splashes::update() src = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).splashes.at(spl.src); spl.life++; if (spl.life > src.lifetime) - { deadIndexes.append(spl.id); - curDead = spl.id; - } //isTowerSplash = true; //if (!isTowerSplash) // src = gameData->srcSplashes.at(spl.src); - - - if (distance2(spl.pos, spl.destination) < src.speed*src.speed) - { - deadIndexes.push_back(spl.id); - curDead = spl.id; - } - if (curDead < 0) - { if (src.autoControl) { + if (distance2(spl.pos, spl.destination) < src.speed*src.speed) + deadIndexes.push_back(spl.id); if (gameData->curAliens.contains(spl.AlienId)) spl.destination = gameData->curAliens.value(spl.AlienId).pos; + arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()); + //if (tmpdy < 0) arctg=arctg+M_PI; + angl = 180.0f*(-arctg)/M_PI; + + spl.angle = angl; + + spl.pos.setX(spl.pos.x() + -src.speed*std::sin(arctg)); + spl.pos.setY(spl.pos.y() + -src.speed*std::cos(arctg)); + } else { + if (!gameData->map->rect().contains(spl.pos.toPoint())) + deadIndexes.push_back(spl.id); + spl.pos.setX(spl.pos.x() + -src.speed*std::sin(-spl.angle*M_PI/180.f)); + spl.pos.setY(spl.pos.y() + -src.speed*std::cos(-spl.angle*M_PI/180.f)); } - arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()); - //if (tmpdy < 0) arctg=arctg+M_PI; - angl = 180.0f*(-arctg)/M_PI; - - spl.angle = angl; - - spl.pos.setX(spl.pos.x() - -src.speed*std::sin(arctg)); - spl.pos.setY(spl.pos.y() - -src.speed*std::cos(arctg)); - } - - // TODO: smooth splash rotate // TODO: activate trigger and more... gameData->curSplashes.insert(spl.id,spl); } for (int j=0; jcurAliens.contains((*i).aim))) (*i).aim = -1; @@ -81,6 +81,13 @@ void Towers::update() //else (*i).aim = -1; } } + // TODO: calculate tower angl + if ((*i).aim > 0) + { + float arctg = std::atan2((*i).pos.x() - gameData->curAliens.value((*i).aim).pos.x(),(*i).pos.y() - gameData->curAliens.value((*i).aim).pos.y()); + //if (tmpdy < 0) arctg=arctg+M_PI; + (*i).angle = 180.0f*(-arctg)/M_PI; + } // TODO: smooth rotate tower to aim if ((*i).reload < stw.reload) (*i).reload++; @@ -90,10 +97,10 @@ void Towers::update() { (*i).reload = 0; emit shot(stw.splashes.at(0), 0, (*i)); - qDebug("shot!"); + //qDebug("shot!"); } } } - qDebug() << "aim=" << (*i).aim; + //qDebug() << "aim=" << (*i).aim; } }