diff --git a/adpainter.cpp b/adpainter.cpp index 49b6f69..c1a12ce 100644 --- a/adpainter.cpp +++ b/adpainter.cpp @@ -3,18 +3,18 @@ adpainter::adpainter(int width, int height, int adpcellsize) { - QString str; - QPixmap tmpAlPixmap; - int i=1; cellsize = adpcellsize; buff = new QPixmap(width,height); background = new QPixmap(width,height); pen = new QPen(); brush = new QBrush(); + QString str; + QPixmap tmpAlPixmap; + int i=1; str.setNum(i); while (i != 0) { str.setNum(i); - tmpAlPixmap.load("./images/Aliens/Al_00_" + str + ".png"); + tmpAlPixmap.load(":/aliens/images/Aliens/Al_00_" + str + ".png"); //qDebug() << tmpAlPixmap.isNull(); if (!tmpAlPixmap.isNull()) { AlienPix.push_back(tmpAlPixmap); @@ -57,7 +57,7 @@ void adpainter::drawgrid() } -void adpainter::drawAliens(QVector path, FPVector * position) +void adpainter::drawAliens(QVector path, FPVector position) { float tmpdx,tmpdy,arctg,tmpdx1,tmpdy1; //unsigned char dd[4]; diff --git a/adpainter.h b/adpainter.h index 5ddab88..ed14b84 100644 --- a/adpainter.h +++ b/adpainter.h @@ -28,7 +28,7 @@ public: void clearcell(QPoint pnt); void clear(); QPixmap * getPixmap(); - void drawAliens(QVector path, FPVector * position); + void drawAliens(QVector path, FPVector position); int AnimAlien, StepAlien; private: QPixmap * buff; diff --git a/alien.cpp b/alien.cpp new file mode 100644 index 0000000..46c20e1 --- /dev/null +++ b/alien.cpp @@ -0,0 +1,255 @@ +#include "alien.h" + +Alien::Alien() +{ +} + + +bool Alien::CreatePath() +{ + for (int i = 0; i < data->size.width(); i++) + { + for (int j = 0; j < data->size.height(); j++) + { + if (TmpCells[i][j] < 0 ) data->Cells[i][j] = -1; + else TmpCells[i][j] = 0; + } + } + QPointF tp; + QPoint start; + QVector tmpPath; + PathIndex = 1; + start.setX(Position.pnt.x()/data->cellsize); + start.setY(Position.pnt.y()/data->cellsize); + tmpPath = InvWaveTrace(data->finish,WaveTrace(start,data->finish)); + if (!tmpPath.isEmpty()) + { + for (int j=0; j<4; j++) + { + path.clear(); + tp = tmpPath[0]; + path.push_back(tp); + for (int i = 0; i < al->path.size() - 1; i++) + { + tp.setX((tmpPath[i].x() + tmpPath[i + 1].x()) / 2.0); + tp.setY((tmpPath[i].y() + tmpPath[i + 1].y()) / 2.0); + path.push_back(tp); + } + tp = tmpPath[tmpPath.size() - 1]; + path.push_back(tp); + tmpPath = path; + } + tmpPath.clear(); + if (path.size() > 10) + { + path.remove(1); + path.remove(2); + path.remove(path.size()-2); + path.remove(path.size()-3); + } + return true; + } + return false; +} + + +void Alien::update() +{ + +} + + +/*bool Aliens::PathIntersect(Alien* Al, Rectangle rect) +{ + //PathIntersect = False + for (int i = Al->PathIndex; i<=Al->path.size(); i++) // To UBound(Al.path(), 1) + if (Al->path[i].x + 0.5 >= rect.x0 - 1 && Al->path[i].x + 0.5 <= rect.x1 + 1) + if (Al->path[i].y + 0.5 >= rect.y0 - 1 && Al->path[i].y + 0.5 <= rect.y1 + 1) + return true; //PathIntersect = True //Exit Function + return false; +}*/ + + +int Alien::WaveTrace(QPoint start, QPoint finish) +{ + bool stop = false; + int step = 2; + QPoint cp, tp; + QRect fr(0, 0, data->size.width(), data->size.height()); + QVector tmpp, curp; + cp = start; + curp.push_back(cp); + TmpCells[cp.x()][cp.y()] = 1; + qDebug() << "trace"; + while (!stop) { + tmpp = curp; + curp.clear(); + stop = true; + for (int i = 0; i < tmpp.size(); i++) { + cp = tmpp[i]; + if (cp == finish) { + TmpCells[cp.x()][cp.y()] = step; + qDebug() << "true"; + return step; + } + tp.setX(cp.x() - 1); + tp.setY(cp.y()); + if (fr.contains(tp) && TmpCells[tp.x()][tp.y()] == 0) { + TmpCells[tp.x()][tp.y()] = step; + curp.push_back(tp); + stop = false; + } + tp.setX(cp.x() + 1); + if (fr.contains(tp) && TmpCells[tp.x()][tp.y()] == 0) { + TmpCells[tp.x()][tp.y()] = step; + curp.push_back(tp); + stop = false; + } + tp.setX(cp.x()); + tp.setY(cp.y() - 1); + if (fr.contains(tp) && TmpCells[tp.x()][tp.y()] == 0) { + TmpCells[tp.x()][tp.y()] = step; + curp.push_back(tp); + stop = false; + } + tp.setY(cp.y() + 1); + if (fr.contains(tp) && TmpCells[tp.x()][tp.y()] == 0) { + TmpCells[tp.x()][tp.y()] = step; + curp.push_back(tp); + stop = false; + } + } + step++; + } + qDebug() << "false"; + return -1; +} + + +QVector Alien::InvWaveTrace(QPoint finish, int cnt) +{ + QPoint wp, Ppnt; + QVector alpath; + int Ind, c, xpp, ypp, xnn, ynn; + unsigned char chk; + Ppnt = wp = finish; + xnn=0; + xpp=0; + ynn=0; + ypp=0; + cnt--; + alpath.push_front(Ppnt); + while (cnt > 1) + { + cnt--; + chk = 0; + Ind = 0; + c = 0; + if (wp.x() - 1 >= 0 && TmpCells[wp.x()-1][wp.y()] == cnt) + { + chk = chk | 0x01; + c++; + } + if (wp.x() + 1 < data->size.width() && TmpCells[wp.x()+1][wp.y()] == cnt) + { + chk = chk | 0x02; + c++; + } + if (wp.y() - 1 >= 0 && TmpCells[wp.x()][wp.y()-1] == cnt) + { + chk = chk | 0x04; + c++; + } + if (wp.y() + 1 < data->size.height() && TmpCells[wp.x()][wp.y()+1] == cnt) + { + chk = chk | 0x08; + c++; + } + if (c == 0 || chk == 0) qDebug() << "ERROR!!!"; + if (c > 1) + { + if ((chk & 0x01)==0x01 && (chk & 0x04)==0x04) + { + if (xnn <= ynn && Ind == 0){ + wp.rx()--; + xnn++; + if (xnn == ynn) xnn++; + Ind = 1; + } else if (Ind == 0) { + wp.ry()--; + ynn++; + ynn++; + Ind = 1; + } + } + if ((chk & 0x02)==0x02 && (chk & 0x04)==0x04) + { + if (xpp <= ynn && Ind == 0){ + wp.rx()++; + xpp++; + if (xpp == ynn) xpp++; + Ind = 1; + } else if (Ind == 0) { + wp.ry()--; + ynn++; + ynn++; + Ind = 1; + } + } + if ((chk & 0x01)==0x01 && (chk & 0x08)==0x08) + { + if (xnn <= ypp && Ind == 0){ + wp.rx()--; + xnn++; + if (xnn == ypp) xnn++; + Ind = 1; + } else if (Ind == 0) { + wp.ry()++; + ypp++; + ypp++; + Ind = 1; + } + } + if ((chk & 0x02)==0x02 && (chk & 0x08)==0x08) + { + if (xpp <= ypp && Ind == 0){ + wp.rx()++; + xpp++; + if (xpp == ypp) xpp++; + Ind = 1; + } else if (Ind == 0) { + wp.ry()++; + ypp++; + ypp++; + Ind = 1; + } + } + } + if (c == 1 || Ind == 0) + { + xnn=0; + xpp=0; + ynn=0; + ypp=0; + if ((chk & 0x01)==0x01) { + wp.rx()--; + xnn++; + } + else if ((chk & 0x02)==0x02) { + wp.rx()++; + xpp++; + } + else if ((chk & 0x04)==0x04) { + wp.ry()--; + ynn++; + } + else if ((chk & 0x08)==0x08) { + wp.ry()++; + ypp++; + } + } + Ppnt = wp; + alpath.push_front(Ppnt); + } + return alpath; +} diff --git a/alien.h b/alien.h new file mode 100644 index 0000000..4233ebe --- /dev/null +++ b/alien.h @@ -0,0 +1,41 @@ +#ifndef ALIEN_H +#define ALIEN_H + +#include "basestruct.h" + +class Alien +{ +public: + Alien(); + bool RecreatePath(); + bool testTrace(QPoint start, QPoint finish); + void setPos(FPVector pos); + void update(); + FPVector pos() const {return Position;} + QVector AlienPath() const {return path;} +private: + int ** TmpCells; + GameData * data; + FPVector Position; + int PicType; + //int FlX; + //int FlY; + //int Armor; + //int Level; + //int Money; + int PathIndex; + int PicIndex; + //int PicIndl; + //int MaxFrame; + //float Health; + float Speed; + float PicFrame; + //float PicI; + //float Regeneration; + QVector path; + + int WaveTrace(QPoint start, QPoint finish); + QVector InvWaveTrace(QPoint finish, int cnt); +}; + +#endif // ALIEN_H diff --git a/aliendefender.pro b/aliendefender.pro index 2654376..2cf08be 100644 --- a/aliendefender.pro +++ b/aliendefender.pro @@ -12,7 +12,8 @@ SOURCES += main.cpp \ udpsender.cpp \ towers.cpp \ map.cpp \ - game.cpp + game.cpp \ + alien.cpp HEADERS += mainwindow.h \ adpainter.h \ aliens.h \ @@ -20,5 +21,7 @@ HEADERS += mainwindow.h \ udpsender.h \ towers.h \ map.h \ - game.h + game.h \ + alien.h FORMS += mainwindow.ui +RESOURCES += images.qrc diff --git a/aliendefender.pro.user b/aliendefender.pro.user index 8013e69..ea0ce49 100644 --- a/aliendefender.pro.user +++ b/aliendefender.pro.user @@ -1,302 +1,347 @@ + + RunConfiguration0-BaseEnvironmentBase + 2 + RunConfiguration0-CommandLineArguments - + RunConfiguration0-ProFile - wavetrace.pro + wavetrace.pro RunConfiguration0-RunConfiguration.name - aliendefender + aliendefender RunConfiguration0-UseDyldImageSuffix - false + false RunConfiguration0-UseTerminal - false + false RunConfiguration0-UserEnvironmentChanges - + RunConfiguration0-UserSetName - true + true + + + RunConfiguration0-UserSetWorkingDirectory + false + + + RunConfiguration0-UserWorkingDirectory + RunConfiguration0-type - Qt4ProjectManager.Qt4RunConfiguration + Qt4ProjectManager.Qt4RunConfiguration + + + RunConfiguration1-BaseEnvironmentBase + 2 RunConfiguration1-CommandLineArguments - + RunConfiguration1-ProFile - aliendefender.pro + aliendefender.pro RunConfiguration1-RunConfiguration.name - aliendefender + aliendefender RunConfiguration1-UseDyldImageSuffix - false + false RunConfiguration1-UseTerminal - false + false RunConfiguration1-UserEnvironmentChanges - + RunConfiguration1-UserSetName - false + false + + + RunConfiguration1-UserSetWorkingDirectory + false + + + RunConfiguration1-UserWorkingDirectory + RunConfiguration1-type - Qt4ProjectManager.Qt4RunConfiguration + Qt4ProjectManager.Qt4RunConfiguration activeRunConfiguration - 1 + 1 activebuildconfiguration - Debug + Debug buildConfiguration-Debug - - Debug - 0 - - /home/andrey/documents/sm11/Alien Defender/ad + + Debug + 0 + 2 + + 2 + /home/andrey/documents/sm11/Alien Defender/ad buildConfiguration-Release - - Release - 0 - + + Release + 0 + 2 + + 0 buildconfiguration-Debug-buildstep0 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-S5Q8zKlbhY,guid=6ef5dd4aeeaf9cb3055a39934b629f00 - DESKTOP_SESSION=gnome - DESKTOP_STARTUP_ID= - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_SOCKET=/tmp/keyring-116Pb7/socket - GTK_MODULES=canberra-gtk-module - GTK_RC_FILES=/etc/gtk/gtkrc:/home/andrey/.gtkrc-1.2-gnome2 - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - 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 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 - SHELL=/bin/bash - SPEECHD_PORT=7560 - SSH_AGENT_PID=1318 - SSH_AUTH_SOCK=/tmp/keyring-116Pb7/socket.ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-9AQSnh/database - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1264754424.556816-274237329 + + Debug + + ALLUSERSPROFILE=C:\Documents and Settings\All Users + APPDATA=C:\Documents and Settings\Andrey\Application Data + COMMONPROGRAMFILES=C:\Program Files\Common Files + COMPUTERNAME=COMP + COMSPEC=C:\WINDOWS\system32\cmd.exe + FP_NO_HOST_CHECK=NO + HOMEDRIVE=C: + HOMEPATH=\Documents and Settings\Andrey + INCLUDE=C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC98\include + LIB=C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib + LOGONSERVER=\\COMP + MSDEVDIR=C:\Program Files\Microsoft Visual Studio\Common\MSDev98 + NUMBER_OF_PROCESSORS=2 + OS=Windows_NT + PATH=D:\Qt\2010.01\mingw\bin;D:\Qt\2010.01\qt\bin;C:\Program Files\PC Connectivity Solution\;C:\Program Files\JavaFX\javafx-sdk1.2\bin;C:\Program Files\JavaFX\javafx-sdk1.2\emulator\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\Bpl;C:\Program Files\Git\cmd;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin + PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH + PROCESSOR_ARCHITECTURE=x86 + PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel + PROCESSOR_LEVEL=6 + PROCESSOR_REVISION=1706 + PROGRAMFILES=C:\Program Files + QTDIR=D:/Qt/2010.01/qt + SESSIONNAME=Console + SYSTEMDRIVE=C: + SYSTEMROOT=C:\WINDOWS + TEMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + TMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + USERDOMAIN=COMP + USERNAME=Andrey + USERPROFILE=C:\Documents and Settings\Andrey + VS90COMNTOOLS=D:\Programming\Microsoft Visual Studio 9.0\Common7\Tools\ + VXIPNPPATH=C:\Program Files\IVI Foundation\VISA\ + WINDIR=C:\WINDOWS - - /home/andrey/documents/sm11/Alien Defender/ad/aliendefender.pro - -spec - /usr/share/qt4/mkspecs/linux-g++ - -r - CONFIG+=debug - -Wall + + C:/aliendefender/aliendefender.pro + -spec + win32-g++ + -r + -Wall - /usr/bin/qmake-qt4 - false - /home/andrey/documents/sm11/Alien Defender/ad - 2 - - -Wall + d:/qt/2010.01/qt/bin/qmake.exe + true + C:/aliendefender + + + -Wall buildconfiguration-Debug-buildstep1 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-S5Q8zKlbhY,guid=6ef5dd4aeeaf9cb3055a39934b629f00 - DESKTOP_SESSION=gnome - DESKTOP_STARTUP_ID= - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_SOCKET=/tmp/keyring-116Pb7/socket - GTK_MODULES=canberra-gtk-module - GTK_RC_FILES=/etc/gtk/gtkrc:/home/andrey/.gtkrc-1.2-gnome2 - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - 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 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 - SHELL=/bin/bash - SPEECHD_PORT=7560 - SSH_AGENT_PID=1318 - SSH_AUTH_SOCK=/tmp/keyring-116Pb7/socket.ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-9AQSnh/database - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1264754424.556816-274237329 + + Debug + + ALLUSERSPROFILE=C:\Documents and Settings\All Users + APPDATA=C:\Documents and Settings\Andrey\Application Data + COMMONPROGRAMFILES=C:\Program Files\Common Files + COMPUTERNAME=COMP + COMSPEC=C:\WINDOWS\system32\cmd.exe + FP_NO_HOST_CHECK=NO + HOMEDRIVE=C: + HOMEPATH=\Documents and Settings\Andrey + INCLUDE=C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC98\include + LIB=C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib + LOGONSERVER=\\COMP + MSDEVDIR=C:\Program Files\Microsoft Visual Studio\Common\MSDev98 + NUMBER_OF_PROCESSORS=2 + OS=Windows_NT + PATH=D:\Qt\2010.01\mingw\bin;D:\Qt\2010.01\qt\bin;C:\Program Files\PC Connectivity Solution\;C:\Program Files\JavaFX\javafx-sdk1.2\bin;C:\Program Files\JavaFX\javafx-sdk1.2\emulator\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\Bpl;C:\Program Files\Git\cmd;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin + PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH + PROCESSOR_ARCHITECTURE=x86 + PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel + PROCESSOR_LEVEL=6 + PROCESSOR_REVISION=1706 + PROGRAMFILES=C:\Program Files + QTDIR=D:/Qt/2010.01/qt + SESSIONNAME=Console + SYSTEMDRIVE=C: + SYSTEMROOT=C:\WINDOWS + TEMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + TMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + USERDOMAIN=COMP + USERNAME=Andrey + USERPROFILE=C:\Documents and Settings\Andrey + VS90COMNTOOLS=D:\Programming\Microsoft Visual Studio 9.0\Common7\Tools\ + VXIPNPPATH=C:\Program Files\IVI Foundation\VISA\ + WINDIR=C:\WINDOWS - - -j3 - -w + false + + -j3 + -w - /usr/bin/make - true - /home/andrey/documents/sm11/Alien Defender/ad - - -j3 + D:/Qt/2010.01/mingw/bin/mingw32-make.exe + true + C:/aliendefender + + -j3 buildconfiguration-Debug-cleanstep0 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-S5Q8zKlbhY,guid=6ef5dd4aeeaf9cb3055a39934b629f00 - DESKTOP_SESSION=gnome - DESKTOP_STARTUP_ID= - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_SOCKET=/tmp/keyring-116Pb7/socket - GTK_MODULES=canberra-gtk-module - GTK_RC_FILES=/etc/gtk/gtkrc:/home/andrey/.gtkrc-1.2-gnome2 - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - 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 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 - SHELL=/bin/bash - SPEECHD_PORT=7560 - SSH_AGENT_PID=1318 - SSH_AUTH_SOCK=/tmp/keyring-116Pb7/socket.ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-9AQSnh/database - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1264754424.556816-274237329 + + Debug + + ALLUSERSPROFILE=C:\Documents and Settings\All Users + APPDATA=C:\Documents and Settings\Andrey\Application Data + COMMONPROGRAMFILES=C:\Program Files\Common Files + COMPUTERNAME=COMP + COMSPEC=C:\WINDOWS\system32\cmd.exe + FP_NO_HOST_CHECK=NO + HOMEDRIVE=C: + HOMEPATH=\Documents and Settings\Andrey + INCLUDE=C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC98\include + LIB=C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib + LOGONSERVER=\\COMP + MSDEVDIR=C:\Program Files\Microsoft Visual Studio\Common\MSDev98 + NUMBER_OF_PROCESSORS=2 + OS=Windows_NT + PATH=D:\Qt\2010.01\mingw\bin;D:\Qt\2010.01\qt\bin;C:\Program Files\PC Connectivity Solution\;C:\Program Files\JavaFX\javafx-sdk1.2\bin;C:\Program Files\JavaFX\javafx-sdk1.2\emulator\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\Bpl;C:\Program Files\Git\cmd;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin + PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH + PROCESSOR_ARCHITECTURE=x86 + PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel + PROCESSOR_LEVEL=6 + PROCESSOR_REVISION=1706 + PROGRAMFILES=C:\Program Files + QTDIR=D:/Qt/2010.01/qt + SESSIONNAME=Console + SYSTEMDRIVE=C: + SYSTEMROOT=C:\WINDOWS + TEMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + TMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp + USERDOMAIN=COMP + USERNAME=Andrey + USERPROFILE=C:\Documents and Settings\Andrey + VS90COMNTOOLS=D:\Programming\Microsoft Visual Studio 9.0\Common7\Tools\ + VXIPNPPATH=C:\Program Files\IVI Foundation\VISA\ + WINDIR=C:\WINDOWS - - clean - -w + true + + clean + -w + + D:/Qt/2010.01/mingw/bin/mingw32-make.exe + true + C:/aliendefender + true + + clean - /usr/bin/make - true - /home/andrey/documents/sm11/Alien Defender/ad buildconfiguration-Release-buildstep0 - - Release - 0 + + Release + buildconfiguration-Release-buildstep1 - - Release + + Release buildconfiguration-Release-cleanstep0 - - Release + + Release buildconfigurations - - Debug - Release + + Debug + Release buildstep0 - - - + + + buildstep1 - - + + buildsteps - - trolltech.qt4projectmanager.qmake - trolltech.qt4projectmanager.make + + trolltech.qt4projectmanager.qmake + trolltech.qt4projectmanager.make cleanstep0 - - - true + + + true cleansteps - - trolltech.qt4projectmanager.make + + trolltech.qt4projectmanager.make defaultFileEncoding - UTF-8 + UTF-8 project - + diff --git a/aliens.cpp b/aliens.cpp index cbc4dfa..439bb51 100644 --- a/aliens.cpp +++ b/aliens.cpp @@ -66,6 +66,7 @@ bool Aliens::CreatePath(Alien * al) for (int i = 0; i < data->size.width(); i++) { for (int j = 0; j < data->size.height(); j++) TmpCells[i][j] = data->Cells[i][j]; } + al->path.clear(); al->PathIndex = 0; if (WaveTrace(al)) @@ -83,7 +84,7 @@ bool Aliens::CreatePath(Alien * al) } tp = al->path[al->path.size() - 1]; tmpPnt.push_back(tp); - qDebug() << tmpPnt.size(); + //qDebug() << tmpPnt.size(); al->path = tmpPnt; //al->Position.pnt.setX(al->path[0].x()*data->cellsize); //al->Position.pnt.setY(al->path[0].y()*data->cellsize); @@ -122,18 +123,18 @@ bool Aliens::WaveTrace(Alien * al) { cp = al->Position.pnt/data->cellsize; curp.push_back(cp); TmpCells[cp.x()][cp.y()] = 1; + qDebug() << "trace"; while (!stop) { - qDebug() << "trace"; tmpp = curp; curp.clear(); - qDebug() << tmpp.size(); + //qDebug() << tmpp.size(); stop = true; for (int i = 0; i < tmpp.size(); i++) { cp = tmpp[i]; if (cp == al->DestPnt) { TmpCells[cp.x()][cp.y()] = step; - qDebug() << "true"; InvWaveTrace(cp, step, al); + qDebug() << "true"; qDebug() << al->path.size(); return true; } diff --git a/aliens.h b/aliens.h index 5db943a..fa1b527 100644 --- a/aliens.h +++ b/aliens.h @@ -2,6 +2,7 @@ #define ALIENS_H #include "basestruct.h" +#include "alien.h" class Aliens { diff --git a/basestruct.h b/basestruct.h index 473920e..ca9bdd7 100644 --- a/basestruct.h +++ b/basestruct.h @@ -29,85 +29,56 @@ struct GameData /*struct Effect { - float Health; - float Speed; - int Armor; - int CntHealth; - int CntSpeed; - int CntArmor; + float Health; + float Speed; + int Armor; + int CntHealth; + int CntSpeed; + int CntArmor; };*/ -/*struct AlienImages -{ - vector pix; -};*/ - - -struct Alien -{ -// unsigned char AName[64]; - FPVector Position; - int PicType; - //int FlX; - //int FlY; - //int Armor; - //int Level; - //int Money; - int PathIndex; - int PicIndex; - //int PicIndl; - //int MaxFrame; - //float Health; - float Speed; - float PicFrame; - //float PicI; - //float Regeneration; - QVector path;//path() As Point - QPoint DestPnt; -// Effect Effects; -}; struct Tower { - //unsigned char TName[64]; - //Rectangle Position; - //float angle; - //int flx; - //int fly; - QPoint Center; - //Point FirePnt; - //int BaseType; - //int Damage; - //float Radius; - //float DamageRadius; - //float FireSpeed; - //float DPS; - //int Level; - //int Cost; - //int UpgradeCost; - //int Aim; - //int FireCnt; - //Effect Effects; + //unsigned char TName[64]; + //Rectangle Position; + //float angle; + //int flx; + //int fly; + QPoint Center; + //Point FirePnt; + //int BaseType; + //int Damage; + //float Radius; + //float DamageRadius; + //float FireSpeed; + //float DPS; + //int Level; + //int Cost; + //int UpgradeCost; + //int Aim; + //int FireCnt; + //Effect Effects; }; /* struct Splash { - FPVector Position; - int flx; - int fly; - Point DestPnt; - int DestAlien; - int BaseType; - int Damage; - float DamageRadius; - float Speed; - Effect Effects; - int PicInd; - float PicFrame; - int MaxFrame; + FPVector Position; + int flx; + int fly; + Point DestPnt; + int DestAlien; + int BaseType; + int Damage; + float DamageRadius; + float Speed; + Effect Effects; + int PicInd; + float PicFrame; + int MaxFrame; }; */ diff --git a/images.qrc b/images.qrc new file mode 100644 index 0000000..c6ec355 --- /dev/null +++ b/images.qrc @@ -0,0 +1,24 @@ + + + images/Aliens/Al_00_0.png + images/Aliens/Al_00_1.png + images/Aliens/Al_00_2.png + images/Aliens/Al_00_3.png + images/Aliens/Al_00_4.png + images/Aliens/Al_00_5.png + images/Aliens/Al_00_6.png + images/Aliens/Al_00_7.png + images/Aliens/Al_00_8.png + images/Aliens/Al_00_9.png + images/Aliens/Al_00_10.png + images/Aliens/Al_00_11.png + images/Aliens/Al_00_12.png + images/Aliens/Al_00_13.png + images/Aliens/Al_00_14.png + images/Aliens/Al_00_15.png + images/Aliens/Al_00_16.png + images/Aliens/Al_00_17.png + images/Aliens/Al_00_18.png + images/Aliens/Al_00_19.png + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 87cd12e..5fec989 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -25,12 +25,13 @@ MainWindow::MainWindow(QWidget *parent) //AnimAlien = 0; timer->start(50); qDebug() << "Load DONE!"; + mousebt = 0; } void MainWindow::ADrender() { - adp->drawAliens(aliens->curAliens[0].path, &aliens->curAliens[0].Position); + adp->drawAliens(aliens->curAliens[0].AlienPath(), aliens->curAliens[0].pos()); this->repaint(); } @@ -46,49 +47,53 @@ void MainWindow::paintEvent(QPaintEvent*) void MainWindow::mouseMoveEvent ( QMouseEvent * event ) { - if (mousebt == 1) ClearCell(event->x(),event->y()); - else SetCell(event->x(),event->y()); + if (mousebt == 1) ClearCell(event->pos()); + if (mousebt == 2) SetCell(event->pos()); } void MainWindow::mousePressEvent ( QMouseEvent * event ) { if (event->button() == Qt::RightButton) { - ClearCell(event->x(),event->y()); + ClearCell(event->pos()); mousebt = 1; - } else { - SetCell(event->x(),event->y()); - mousebt = 0; + return; } + if(event->button() == Qt::LeftButton) { + SetCell(event->pos()); + mousebt = 2; + return; + } + mousebt = 0; } -void MainWindow::SetCell(int x, int y) +void MainWindow::SetCell(QPoint pos) { QPoint cp; QRect wdrect(0, 0, (this->width() / cellsize) * cellsize, (this->height() / cellsize) * cellsize); - if (wdrect.contains(x,y)) { - cp.setX((int) x / cellsize); - cp.setY((int) y / cellsize); + if (wdrect.contains(pos)) { + cp.setX(pos.x()/cellsize); + cp.setY(pos.y()/cellsize); //qDebug() << "click: " << cp.x() << ";" << cp.y(); GameMain->data->Cells[cp.x()][cp.y()] = - 1; adp->drawcell(cp); //aliens->clearAliens(); //adp->StepAlien=0; //adp->AnimAlien=0; - if (!aliens->CreatePath(&(aliens->curAliens[0]))) ClearCell(x,y); + if (!aliens->CreatePath(&(aliens->curAliens[0]))) ClearCell(pos); else adp->StepAlien=0; } } -void MainWindow::ClearCell(int x, int y) +void MainWindow::ClearCell(QPoint pos) { QPoint cp; QRect wdrect(0, 0, (this->width() / cellsize) * cellsize, (this->height() / cellsize) * cellsize); - if (wdrect.contains(x,y)) { - cp.setX((int) x / cellsize); - cp.setY((int) y / cellsize); + if (wdrect.contains(pos)) { + cp.setX(pos.x()/cellsize); + cp.setY(pos.y()/cellsize); //qDebug() << "click: " << cp.x() << ";" << cp.y(); GameMain->data->Cells[cp.x()][cp.y()] = 0; adp->clearcell(cp); diff --git a/mainwindow.h b/mainwindow.h index 4587e7a..043479a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -25,8 +25,8 @@ public slots: void ADrender(); private: void paintEvent(QPaintEvent*); - void SetCell(int x, int y); - void ClearCell(int x, int y); + void SetCell(QPoint pos); + void ClearCell(QPoint pos); void mouseMoveEvent ( QMouseEvent * event ); void mousePressEvent ( QMouseEvent * event ); Ui::MainWindow *ui; @@ -35,7 +35,7 @@ private: adpainter * adp; game * GameMain; QTimer *timer; - bool mousebt; + int mousebt; int cellsize, destx, desty; //unsigned int AnimAlien; };