diff --git a/AlienDefender b/AlienDefender deleted file mode 100644 index ce01362..0000000 --- a/AlienDefender +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/Makefile b/Makefile index 7bcbf19..a7d4447 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,21 @@ ############################################################################# -# Makefile for building: wavetrace -# Generated by qmake (2.01a) (Qt 4.5.2) on: ?? ????. 2 15:18:59 2009 -# Project: wavetrace.pro +# Makefile for building: aliendefender +# Generated by qmake (2.01a) (Qt 4.5.2) on: ?? ????. 3 22:49:40 2009 +# Project: aliendefender.pro # Template: app -# Command: /usr/bin/qmake -Wall -spec ../../../../share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile wavetrace.pro +# Command: /usr/bin/qmake -unix -o Makefile aliendefender.pro ############################################################################# ####### Compiler, tools and options CC = gcc CXX = g++ -DEFINES = -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) -CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) -INCPATH = -I../../../../share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/include -I. -I. +DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -march=native -O2 -pipe -fomit-frame-pointer -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -march=native -O2 -pipe -fomit-frame-pointer -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I../../share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/include -I. -I. LINK = g++ -LFLAGS = +LFLAGS = -Wl,-O1 LIBS = $(SUBLIBS) -L/usr/lib/qt4 -L/usr/X11R6/lib -lQtOpenGL -L/usr/lib/qt4 -L/usr/X11R6/lib -pthread -pthread -pthread -pthread -pthread -pthread -pthread -pthread -lQtGui -pthread -lpng -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lXrandr -lXinerama -lfontconfig -lXext -lX11 -lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lGLU -lGL -lpthread AR = ar cqs RANLIB = @@ -57,30 +57,30 @@ OBJECTS = main.o \ towers.o \ moc_mainwindow.o \ moc_udpsender.o -DIST = ../../../../share/qt4/mkspecs/common/g++.conf \ - ../../../../share/qt4/mkspecs/common/unix.conf \ - ../../../../share/qt4/mkspecs/common/linux.conf \ - ../../../../share/qt4/mkspecs/qconfig.pri \ - ../../../../share/qt4/mkspecs/features/qt_functions.prf \ - ../../../../share/qt4/mkspecs/features/qt_config.prf \ - ../../../../share/qt4/mkspecs/features/exclusive_builds.prf \ - ../../../../share/qt4/mkspecs/features/default_pre.prf \ - ../../../../share/qt4/mkspecs/features/debug.prf \ - ../../../../share/qt4/mkspecs/features/default_post.prf \ - ../../../../share/qt4/mkspecs/features/warn_on.prf \ - ../../../../share/qt4/mkspecs/features/qt.prf \ - ../../../../share/qt4/mkspecs/features/unix/opengl.prf \ - ../../../../share/qt4/mkspecs/features/unix/thread.prf \ - ../../../../share/qt4/mkspecs/features/moc.prf \ - ../../../../share/qt4/mkspecs/features/resources.prf \ - ../../../../share/qt4/mkspecs/features/uic.prf \ - ../../../../share/qt4/mkspecs/features/yacc.prf \ - ../../../../share/qt4/mkspecs/features/lex.prf \ - ../../../../share/qt4/mkspecs/features/include_source_dir.prf \ - wavetrace.pro -QMAKE_TARGET = wavetrace +DIST = ../../share/qt4/mkspecs/common/g++.conf \ + ../../share/qt4/mkspecs/common/unix.conf \ + ../../share/qt4/mkspecs/common/linux.conf \ + ../../share/qt4/mkspecs/qconfig.pri \ + ../../share/qt4/mkspecs/features/qt_functions.prf \ + ../../share/qt4/mkspecs/features/qt_config.prf \ + ../../share/qt4/mkspecs/features/exclusive_builds.prf \ + ../../share/qt4/mkspecs/features/default_pre.prf \ + ../../share/qt4/mkspecs/features/release.prf \ + ../../share/qt4/mkspecs/features/default_post.prf \ + ../../share/qt4/mkspecs/features/warn_on.prf \ + ../../share/qt4/mkspecs/features/qt.prf \ + ../../share/qt4/mkspecs/features/unix/opengl.prf \ + ../../share/qt4/mkspecs/features/unix/thread.prf \ + ../../share/qt4/mkspecs/features/moc.prf \ + ../../share/qt4/mkspecs/features/resources.prf \ + ../../share/qt4/mkspecs/features/uic.prf \ + ../../share/qt4/mkspecs/features/yacc.prf \ + ../../share/qt4/mkspecs/features/lex.prf \ + ../../share/qt4/mkspecs/features/include_source_dir.prf \ + aliendefender.pro +QMAKE_TARGET = aliendefender DESTDIR = -TARGET = wavetrace +TARGET = aliendefender first: all ####### Implicit rules @@ -109,61 +109,61 @@ all: Makefile $(TARGET) $(TARGET): ui_mainwindow.h $(OBJECTS) $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) -Makefile: wavetrace.pro ../../../../share/qt4/mkspecs/linux-g++/qmake.conf ../../../../share/qt4/mkspecs/common/g++.conf \ - ../../../../share/qt4/mkspecs/common/unix.conf \ - ../../../../share/qt4/mkspecs/common/linux.conf \ - ../../../../share/qt4/mkspecs/qconfig.pri \ - ../../../../share/qt4/mkspecs/features/qt_functions.prf \ - ../../../../share/qt4/mkspecs/features/qt_config.prf \ - ../../../../share/qt4/mkspecs/features/exclusive_builds.prf \ - ../../../../share/qt4/mkspecs/features/default_pre.prf \ - ../../../../share/qt4/mkspecs/features/debug.prf \ - ../../../../share/qt4/mkspecs/features/default_post.prf \ - ../../../../share/qt4/mkspecs/features/warn_on.prf \ - ../../../../share/qt4/mkspecs/features/qt.prf \ - ../../../../share/qt4/mkspecs/features/unix/opengl.prf \ - ../../../../share/qt4/mkspecs/features/unix/thread.prf \ - ../../../../share/qt4/mkspecs/features/moc.prf \ - ../../../../share/qt4/mkspecs/features/resources.prf \ - ../../../../share/qt4/mkspecs/features/uic.prf \ - ../../../../share/qt4/mkspecs/features/yacc.prf \ - ../../../../share/qt4/mkspecs/features/lex.prf \ - ../../../../share/qt4/mkspecs/features/include_source_dir.prf \ +Makefile: aliendefender.pro ../../share/qt4/mkspecs/linux-g++/qmake.conf ../../share/qt4/mkspecs/common/g++.conf \ + ../../share/qt4/mkspecs/common/unix.conf \ + ../../share/qt4/mkspecs/common/linux.conf \ + ../../share/qt4/mkspecs/qconfig.pri \ + ../../share/qt4/mkspecs/features/qt_functions.prf \ + ../../share/qt4/mkspecs/features/qt_config.prf \ + ../../share/qt4/mkspecs/features/exclusive_builds.prf \ + ../../share/qt4/mkspecs/features/default_pre.prf \ + ../../share/qt4/mkspecs/features/release.prf \ + ../../share/qt4/mkspecs/features/default_post.prf \ + ../../share/qt4/mkspecs/features/warn_on.prf \ + ../../share/qt4/mkspecs/features/qt.prf \ + ../../share/qt4/mkspecs/features/unix/opengl.prf \ + ../../share/qt4/mkspecs/features/unix/thread.prf \ + ../../share/qt4/mkspecs/features/moc.prf \ + ../../share/qt4/mkspecs/features/resources.prf \ + ../../share/qt4/mkspecs/features/uic.prf \ + ../../share/qt4/mkspecs/features/yacc.prf \ + ../../share/qt4/mkspecs/features/lex.prf \ + ../../share/qt4/mkspecs/features/include_source_dir.prf \ /usr/lib/qt4/libQtOpenGL.prl \ /usr/lib/qt4/libQtGui.prl \ /usr/lib/qt4/libQtCore.prl \ /usr/lib/qt4/libQtNetwork.prl - $(QMAKE) -Wall -spec ../../../../share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile wavetrace.pro -../../../../share/qt4/mkspecs/common/g++.conf: -../../../../share/qt4/mkspecs/common/unix.conf: -../../../../share/qt4/mkspecs/common/linux.conf: -../../../../share/qt4/mkspecs/qconfig.pri: -../../../../share/qt4/mkspecs/features/qt_functions.prf: -../../../../share/qt4/mkspecs/features/qt_config.prf: -../../../../share/qt4/mkspecs/features/exclusive_builds.prf: -../../../../share/qt4/mkspecs/features/default_pre.prf: -../../../../share/qt4/mkspecs/features/debug.prf: -../../../../share/qt4/mkspecs/features/default_post.prf: -../../../../share/qt4/mkspecs/features/warn_on.prf: -../../../../share/qt4/mkspecs/features/qt.prf: -../../../../share/qt4/mkspecs/features/unix/opengl.prf: -../../../../share/qt4/mkspecs/features/unix/thread.prf: -../../../../share/qt4/mkspecs/features/moc.prf: -../../../../share/qt4/mkspecs/features/resources.prf: -../../../../share/qt4/mkspecs/features/uic.prf: -../../../../share/qt4/mkspecs/features/yacc.prf: -../../../../share/qt4/mkspecs/features/lex.prf: -../../../../share/qt4/mkspecs/features/include_source_dir.prf: + $(QMAKE) -unix -o Makefile aliendefender.pro +../../share/qt4/mkspecs/common/g++.conf: +../../share/qt4/mkspecs/common/unix.conf: +../../share/qt4/mkspecs/common/linux.conf: +../../share/qt4/mkspecs/qconfig.pri: +../../share/qt4/mkspecs/features/qt_functions.prf: +../../share/qt4/mkspecs/features/qt_config.prf: +../../share/qt4/mkspecs/features/exclusive_builds.prf: +../../share/qt4/mkspecs/features/default_pre.prf: +../../share/qt4/mkspecs/features/release.prf: +../../share/qt4/mkspecs/features/default_post.prf: +../../share/qt4/mkspecs/features/warn_on.prf: +../../share/qt4/mkspecs/features/qt.prf: +../../share/qt4/mkspecs/features/unix/opengl.prf: +../../share/qt4/mkspecs/features/unix/thread.prf: +../../share/qt4/mkspecs/features/moc.prf: +../../share/qt4/mkspecs/features/resources.prf: +../../share/qt4/mkspecs/features/uic.prf: +../../share/qt4/mkspecs/features/yacc.prf: +../../share/qt4/mkspecs/features/lex.prf: +../../share/qt4/mkspecs/features/include_source_dir.prf: /usr/lib/qt4/libQtOpenGL.prl: /usr/lib/qt4/libQtGui.prl: /usr/lib/qt4/libQtCore.prl: /usr/lib/qt4/libQtNetwork.prl: qmake: FORCE - @$(QMAKE) -Wall -spec ../../../../share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile wavetrace.pro + @$(QMAKE) -unix -o Makefile aliendefender.pro dist: - @$(CHK_DIR_EXISTS) .tmp/wavetrace1.0.0 || $(MKDIR) .tmp/wavetrace1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/wavetrace1.0.0/ && $(COPY_FILE) --parents mainwindow.h adpainter.h aliens.h basestruct.h udpsender.h towers.h .tmp/wavetrace1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp adpainter.cpp aliens.cpp udpsender.cpp towers.cpp .tmp/wavetrace1.0.0/ && $(COPY_FILE) --parents mainwindow.ui .tmp/wavetrace1.0.0/ && (cd `dirname .tmp/wavetrace1.0.0` && $(TAR) wavetrace1.0.0.tar wavetrace1.0.0 && $(COMPRESS) wavetrace1.0.0.tar) && $(MOVE) `dirname .tmp/wavetrace1.0.0`/wavetrace1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/wavetrace1.0.0 + @$(CHK_DIR_EXISTS) .tmp/aliendefender1.0.0 || $(MKDIR) .tmp/aliendefender1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/aliendefender1.0.0/ && $(COPY_FILE) --parents mainwindow.h adpainter.h aliens.h basestruct.h udpsender.h towers.h .tmp/aliendefender1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp adpainter.cpp aliens.cpp udpsender.cpp towers.cpp .tmp/aliendefender1.0.0/ && $(COPY_FILE) --parents mainwindow.ui .tmp/aliendefender1.0.0/ && (cd `dirname .tmp/aliendefender1.0.0` && $(TAR) aliendefender1.0.0.tar aliendefender1.0.0 && $(COMPRESS) aliendefender1.0.0.tar) && $(MOVE) `dirname .tmp/aliendefender1.0.0`/aliendefender1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/aliendefender1.0.0 clean:compiler_clean diff --git a/adpainter.cpp b/adpainter.cpp index f9a11fe..17e5a51 100644 --- a/adpainter.cpp +++ b/adpainter.cpp @@ -57,12 +57,13 @@ void adpainter::drawgrid() } -void adpainter::drawAliens(deque path, FPVector * position) +void adpainter::drawAliens(QVector path, FPVector * position) { float tmpdx,tmpdy,arctg,tmpdx1,tmpdy1; //unsigned char dd[4]; //int gg; arctg = 0; + //qDebug() << path.size(); //QTransform rotated; painter.begin(buff); pen->setColor(QColor::fromRgb(qRgb(80,200,100))); @@ -71,22 +72,23 @@ void adpainter::drawAliens(deque path, FPVector * position) painter.setPen(*pen); painter.setBrush(*brush); painter.drawPixmap(0,0,*background); - for (unsigned int i = 0; i < path.size(); i++){ + for (int i = 0; i < path.size(); i++){ painter.drawEllipse(path[i].x() * cellsize +1, path[i].y() * cellsize +1, cellsize - 2, cellsize - 2); } tmpdx = position->pnt.x() - path.at(StepAlien).x()*cellsize; tmpdy = position->pnt.y() - path.at(StepAlien).y()*cellsize; - if (StepAlien + 2 < path.size()) { - tmpdx1 = position->pnt.x() - path.at(StepAlien+2).x()*cellsize; - tmpdy1 = position->pnt.y() - path.at(StepAlien+2).y()*cellsize; + if (StepAlien + 1 < path.size()) { + tmpdx1 = position->pnt.x() - path.at(StepAlien+1).x()*cellsize; + tmpdy1 = position->pnt.y() - path.at(StepAlien+1).y()*cellsize; } arctg = atanf(tmpdx1/tmpdy1); //memcpy(&gg,&arctg,4); - if (tmpdy1 != 0) position->angle = 180*(-arctg)/3.1415; + position->angle = 180*(-arctg)/3.1415; + if (tmpdy1 < 0) position->angle = 180 + position->angle; if (AlienPix.size() > 0) { //painter.rotate((arctg/3.1415)*180); //rotated.rotateRadians(arctg/* + 3.1415/2*/); - //qDebug() << "angle:" << arctg; + qDebug() << "angle:" << position->angle; //rotated.reset(); if (qAbs(tmpdx) < 1 && qAbs(tmpdy) < 1) StepAlien++; else { @@ -108,16 +110,16 @@ void adpainter::drawAliens(deque path, FPVector * position) } } //painter.save(); - painter.translate(position->pnt.x()-cellsize,position->pnt.y()-cellsize); + painter.translate(position->pnt.x()+cellsize/2, position->pnt.y()+cellsize/2); //if (arctg == 0) painter.rotate(90); //memcpy(dd,&gg,4); //dd[0]=0xFF; - qDebug() << "angle:" << position->angle; + //qDebug() << "angle:" << position->angle; //qDebug() << dd[0] << dd[1] << dd[2] << dd[3]; painter.rotate(position->angle); //position->pnt.setX(path.at(0).x()); //position->pnt.setY(path.at(0).y()); - painter.drawPixmap(cellsize/2, cellsize/2, cellsize*2, cellsize*2, AlienPix.at(AnimAlien)); + painter.drawPixmap(-cellsize, -cellsize, cellsize*2, cellsize*2, AlienPix.at(AnimAlien)); AnimAlien++; //painter.restore(); if (AnimAlien >= AlienPix.size()) AnimAlien = 0; diff --git a/adpainter.h b/adpainter.h index f43114c..b9f02de 100644 --- a/adpainter.h +++ b/adpainter.h @@ -3,7 +3,7 @@ #include "basestruct.h" -#include +//#include #include #include @@ -18,8 +18,8 @@ #include #include -using std::deque; -using std::vector; +//using std::deque; +//using std::vector; using std::atan; class adpainter @@ -31,15 +31,15 @@ public: void clearcell(QPoint pnt); void clear(); QPixmap * getPixmap(); - void drawAliens(deque path, FPVector * position);//int xa, int ya); - unsigned int AnimAlien, StepAlien; + void drawAliens(QVector path, FPVector * position);//int xa, int ya); + int AnimAlien, StepAlien; private: QPixmap * buff; QPixmap * background; QPainter painter; QPen * pen; QBrush * brush; - vector AlienPix; + QVector AlienPix; int cellsize; }; diff --git a/adpainter.o b/adpainter.o index 355cdac..f7ce176 100644 Binary files a/adpainter.o and b/adpainter.o differ diff --git a/aliendefender b/aliendefender new file mode 100755 index 0000000..eb18e63 Binary files /dev/null and b/aliendefender differ diff --git a/wavetrace.pro b/aliendefender.pro similarity index 95% rename from wavetrace.pro rename to aliendefender.pro index 2caa513..4c8be6e 100644 --- a/wavetrace.pro +++ b/aliendefender.pro @@ -3,7 +3,7 @@ # ------------------------------------------------- QT += network \ opengl -TARGET = wavetrace +TARGET = aliendefender TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ diff --git a/wavetrace.pro.user b/aliendefender.pro.user similarity index 100% rename from wavetrace.pro.user rename to aliendefender.pro.user diff --git a/aliens.cpp b/aliens.cpp index 8b3f778..f8036be 100644 --- a/aliens.cpp +++ b/aliens.cpp @@ -1,16 +1,16 @@ #include "aliens.h" -using std::vector; +//using std::vector; Aliens::Aliens(int TmpDestx, int TmpDesty, int afw, int afh, int alcellsize) { cellsize = alcellsize; - DestPoint.setX(TmpDestx); + DestPoint.setX(TmpDestx - 1); DestPoint.setY(TmpDesty); fw = afw; fh = afh; - AliensCnt = -1; - CurWave = 0; + //AliensCnt = -1; + //CurWave = 0; Cells = new int*[fw]; TmpCells = new int*[fw]; for (int i = 0; i < fw; i++) { @@ -21,6 +21,29 @@ Aliens::Aliens(int TmpDestx, int TmpDesty, int afw, int afh, int alcellsize) } +int Aliens::loadAlienImages(int PicType) +{ + int i = 1; + QString str1,str2; + QPixmap tmpAlPixmap; + str1.setNum(i); + str2.setNum(PicType); + while (i != 0) { + str1.setNum(i); + tmpAlPixmap.load("./images/Aliens/Al_" + str2 + "_" + str1 + ".png"); + qDebug() << tmpAlPixmap.isNull(); + if (!tmpAlPixmap.isNull()) { + //AlienPix.push_back(tmpAlPixmap); + tmpAlPixmap = 0; + i++; + } + else i = 0; + } + //qDebug() << "pictures:" << AlienPix.size(); + return i; +} + + void Aliens::clearCells() { for (int i = 0; i < fw; i++) for (int j = 0; j < fh; j++) Cells[i][j] = 0; @@ -29,33 +52,32 @@ void Aliens::clearCells() bool Aliens::AddAlien() { - bool ok; + //bool ok; Alien al; - AliensCnt++; + //AliensCnt++; //if (CurWave < 0) CurWave = 0; - //if (AliensCnt > curAliens.size()) ReDim Preserve Aliens(AliensCnt) As Alien - //Aliens(AliensCnt) = SrcAliens(CurWave) + //if (AliensCnt > curAliens.size()) ReDim Preserve Aliens(AliensCnt) As Alien + //Aliens(AliensCnt) = SrcAliens(CurWave) curAliens.push_back(al); //srcAliens[CurWave]); -// curAliens[AliensCnt].Level = CurWave + 1; - curAliens[AliensCnt].Position.pnt.setX(0); - curAliens[AliensCnt].Position.pnt.setY(fh/2); //(int)(fh/2+(1-0.58)*6); - DestPoint.setX(fw - 1); - DestPoint.setY(fh / 2); //curAliens[AliensCnt].Position.pnt.y(); - curAliens[AliensCnt].DestPnt = DestPoint; + //curAliens[AliensCnt].Level = CurWave + 1; + curAliens[0].Position.pnt.setX(0); + curAliens[0].Position.pnt.setY(fh/2); //(int)(fh/2+(1-0.58)*6); + //DestPoint.setX(fw - 1); + //DestPoint.setY(fh / 2); //curAliens[AliensCnt].Position.pnt.y(); + curAliens[0].DestPnt = DestPoint; // curAliens[AliensCnt].MaxFrame = 0; //srcAliens[CurWave].MaxFrame; // curAliens[AliensCnt].PicFrame = 0; for (int i = 0; i < fw; i++) { for (int j = 0; j < fh; j++) TmpCells[i][j] = Cells[i][j]; } - ok = CreatePath(&curAliens[AliensCnt]); - return ok; + return CreatePath(&curAliens[0]); } bool Aliens::CreatePath(Alien * al) { QPointF tp; - deque tmpPnt; + QVector tmpPnt; //tmpPnt.clear(); // AliensTmpDestX = fw - 1;//al->Destpnt.x(); // AliensTmpDestY = fh / 2;//al->Destpnt.y(); @@ -68,7 +90,7 @@ bool Aliens::CreatePath(Alien * al) tmpPnt.clear(); tp = al->path[0]; tmpPnt.push_back(tp); - for (unsigned int i = 0; i < al->path.size() - 1; i++) + for (int i = 0; i < al->path.size() - 1; i++) { tp.setX((al->path[i].x() + al->path[i + 1].x()) / 2); tp.setY((al->path[i].y() + al->path[i + 1].y()) / 2); @@ -76,17 +98,12 @@ bool Aliens::CreatePath(Alien * al) } tp = al->path[al->path.size() - 1]; tmpPnt.push_back(tp); - al->path.swap(tmpPnt); + qDebug() << tmpPnt.size(); + al->path = tmpPnt; al->Position.pnt.setX(al->path.at(0).x()*cellsize); al->Position.pnt.setY(al->path.at(0).y()*cellsize); } - int i = 0; tmpPnt.clear(); - while(1) - { - tp = al->path[0]; - break; - } return true; } return false; @@ -94,6 +111,12 @@ bool Aliens::CreatePath(Alien * al) } +void Aliens::updateAlienPos(Alien * al) +{ + +} + + /*bool Aliens::PathIntersect(Alien* Al, Rectangle rect) { //PathIntersect = False @@ -110,15 +133,17 @@ bool Aliens::WaveTrace(Alien * al) { int step = 2; QPoint cp, tp; QRect fr(0, 0, fw, fh); - vector tmpp, curp; + QVector tmpp, curp; cp = al->Position.pnt; curp.push_back(cp); TmpCells[cp.x()][cp.y()] = 1; while (!stop) { - tmpp = curp; + qDebug() << "trace"; + tmpp = curp; curp.clear(); + qDebug() << tmpp.size(); stop = true; - for (unsigned int i = 0; i < tmpp.size(); i++) { + for (int i = 0; i < tmpp.size(); i++) { cp = tmpp[i]; if (cp == al->DestPnt) { TmpCells[cp.x()][cp.y()] = step; @@ -292,6 +317,6 @@ void Aliens::InvWaveTrace(QPoint cp, int cnt, Alien * al) void Aliens::clearAliens() { - AliensCnt = - 1; + //AliensCnt = - 1; curAliens.clear(); } diff --git a/aliens.h b/aliens.h index 2fa85e4..117a1dc 100644 --- a/aliens.h +++ b/aliens.h @@ -9,22 +9,27 @@ class Aliens public: Aliens(int TmpDestx, int TmpDesty, int afw, int afh, int alcellsize); - deque srcAliens; - deque curAliens; + QVector srcAliens; + QVector curAliens; //vector< vector > TmpCells; int ** Cells; - int fw, fh, AliensCnt, CurWave; - QPoint DestPoint; //bool PathIntersect(Alien* Al, Rectangle rect); + bool AddAlien(); void clearAliens(); void clearCells(); private: int cellsize; int ** TmpCells; + int fw, fh; + QPoint DestPoint; + QVector< QVector > AliensPixmaps; + //AlienImages AliensPixmaps[1]; bool CreatePath(Alien* al); bool WaveTrace(Alien* al); void InvWaveTrace(QPoint cp, int cnt, Alien* al); + void updateAlienPos(Alien * al); + int loadAlienImages(int PicType); }; #endif // ALIENS_H diff --git a/aliens.o b/aliens.o index ffeee2b..f792657 100644 Binary files a/aliens.o and b/aliens.o differ diff --git a/basestruct.h b/basestruct.h index 1ebfcf5..541bd6b 100644 --- a/basestruct.h +++ b/basestruct.h @@ -1,15 +1,17 @@ #ifndef BASESTRUCT_H #define BASESTRUCT_H -#include -#include +#include +//#include #include +#include +#include #include #include #include -using std::vector; -using std::deque; +//using std::vector; +//using std::deque; struct FPVector @@ -18,8 +20,8 @@ struct FPVector float angle; }; -/* -struct Effect + +/*struct Effect { float Health; float Speed; @@ -27,27 +29,35 @@ struct Effect int CntHealth; int CntSpeed; int CntArmor; -}; -*/ +};*/ + + +/*struct AlienImages +{ + vector pix; +};*/ + struct Alien { // unsigned char AName[64]; FPVector Position; -/* int FlX; - int FlY; - int Armor; - int Level; - int Money; + int PicType; + //int FlX; + //int FlY; + //int Armor; + //int Level; + //int Money; int PathIndex; - int PicIndl; - int MaxFrame; - float Health; + int PicIndex; + //int PicIndl; + //int MaxFrame; + //float Health; float Speed; float PicFrame; - float PicInc; - float Regeneration;*/ - deque path;//path() As Point + //float PicI; + //float Regeneration; + QVector path;//path() As Point QPoint DestPnt; // Effect Effects; }; diff --git a/main.o b/main.o index 9c7060c..4b9eb43 100644 Binary files a/main.o and b/main.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index ca4b0ac..d923635 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5,12 +5,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + qDebug() << "Load START!"; ui->setupUi(this); sndr = new UdpSender("127.0.0.1",10101); sndr->connectSend("hellow"); cellsize = 16; - destx = this->width() / cellsize / 2; - desty = this->height() / cellsize; + destx = this->width() / cellsize; + desty = this->height() / cellsize / 2; QTimer *timer = new QTimer(this); adp = new adpainter(this->width(),this->height(),cellsize); adp->clear(); @@ -22,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent) //qDebug() << "QT version" << qVersion(); //AnimAlien = 0; timer->start(50); + qDebug() << "Load DONE!"; } diff --git a/mainwindow.o b/mainwindow.o index 3fa7721..92a4a80 100644 Binary files a/mainwindow.o and b/mainwindow.o differ diff --git a/moc_mainwindow.cpp b/moc_mainwindow.cpp index df95c2a..c472b24 100644 --- a/moc_mainwindow.cpp +++ b/moc_mainwindow.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** -** Created: Mon Aug 31 09:51:05 2009 +** Created: Thu Sep 3 22:52:32 2009 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2) ** ** WARNING! All changes made in this file will be lost! diff --git a/moc_mainwindow.o b/moc_mainwindow.o index bdf3b6b..ffffa15 100644 Binary files a/moc_mainwindow.o and b/moc_mainwindow.o differ diff --git a/moc_udpsender.cpp b/moc_udpsender.cpp index e6593ef..e7cb967 100644 --- a/moc_udpsender.cpp +++ b/moc_udpsender.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'udpsender.h' ** -** Created: Mon Aug 31 09:51:08 2009 +** Created: Thu Sep 3 22:52:35 2009 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2) ** ** WARNING! All changes made in this file will be lost! diff --git a/moc_udpsender.o b/moc_udpsender.o index 2557300..f41c305 100644 Binary files a/moc_udpsender.o and b/moc_udpsender.o differ diff --git a/towers.h b/towers.h index 3855869..1b7bb33 100644 --- a/towers.h +++ b/towers.h @@ -7,8 +7,8 @@ class towers { public: towers(); - deque srcTowers; - deque curTowers; + QVector srcTowers; + QVector curTowers; void AddTower(QPointF point, int ** cells); }; diff --git a/towers.o b/towers.o index ff6ce4f..87498a0 100644 Binary files a/towers.o and b/towers.o differ diff --git a/udpsender.cpp b/udpsender.cpp index b39f3ea..0f9d1d8 100644 --- a/udpsender.cpp +++ b/udpsender.cpp @@ -26,10 +26,10 @@ void UdpSender::slotRead() QByteArray * recdata = new QByteArray(); *recdata = sock->readAll(); s = *recdata; - cout << "Received data: "; - for (int i = 0; i < s.length(); i++) cout << s[i].toAscii(); - cout << endl; - qDebug() << sock->write(recstr.toUtf8()); + qDebug() << "Received data: " << s; + //for (int i = 0; i < s.length(); i++) cout << s[i].toAscii(); + //cout << endl; + //qDebug() << sock->write(recstr.toUtf8()); qDebug() << sock->socketDescriptor(); } diff --git a/udpsender.h b/udpsender.h index 1151d9e..dae269b 100644 --- a/udpsender.h +++ b/udpsender.h @@ -1,9 +1,9 @@ #include #include -#include +//#include -using std::cout; -using std::endl; +//using std::cout; +//using std::endl; class UdpSender : public QObject { diff --git a/udpsender.o b/udpsender.o index 035c395..76312ef 100644 Binary files a/udpsender.o and b/udpsender.o differ diff --git a/ui_mainwindow.h b/ui_mainwindow.h index 38b4522..6f898a7 100644 --- a/ui_mainwindow.h +++ b/ui_mainwindow.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading ui file 'mainwindow.ui' ** -** Created: Mon Aug 31 09:50:43 2009 +** Created: Thu Sep 3 22:52:10 2009 ** by: Qt User Interface Compiler version 4.5.2 ** ** WARNING! All changes made in this file will be lost when recompiling ui file! diff --git a/wavetrace b/wavetrace deleted file mode 100755 index c3fcce7..0000000 Binary files a/wavetrace and /dev/null differ