the Alien going right!

This commit is contained in:
2009-09-03 22:56:39 +04:00
parent 7ecbd3764c
commit 5ec3aa2be9
26 changed files with 203 additions and 160 deletions

View File

@@ -1 +0,0 @@
hello

152
Makefile
View File

@@ -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

View File

@@ -57,12 +57,13 @@ void adpainter::drawgrid()
}
void adpainter::drawAliens(deque<QPointF> path, FPVector * position)
void adpainter::drawAliens(QVector<QPointF> 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<QPointF> 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<QPointF> 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;

View File

@@ -3,7 +3,7 @@
#include "basestruct.h"
#include <vector>
//#include <vector>
#include <cmath>
#include <QPainter>
@@ -18,8 +18,8 @@
#include <QPoint>
#include <QDebug>
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<QPointF> path, FPVector * position);//int xa, int ya);
unsigned int AnimAlien, StepAlien;
void drawAliens(QVector<QPointF> path, FPVector * position);//int xa, int ya);
int AnimAlien, StepAlien;
private:
QPixmap * buff;
QPixmap * background;
QPainter painter;
QPen * pen;
QBrush * brush;
vector<QPixmap> AlienPix;
QVector<QPixmap> AlienPix;
int cellsize;
};

Binary file not shown.

BIN
aliendefender Executable file

Binary file not shown.

View File

@@ -3,7 +3,7 @@
# -------------------------------------------------
QT += network \
opengl
TARGET = wavetrace
TARGET = aliendefender
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp \

View File

@@ -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<QPointF> tmpPnt;
QVector<QPointF> 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<QPoint> tmpp, curp;
QVector<QPoint> 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();
}

View File

@@ -9,22 +9,27 @@ class Aliens
public:
Aliens(int TmpDestx, int TmpDesty, int afw, int afh, int alcellsize);
deque<Alien> srcAliens;
deque<Alien> curAliens;
QVector<Alien> srcAliens;
QVector<Alien> curAliens;
//vector< vector<int> > 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<QPixmap> > 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

BIN
aliens.o

Binary file not shown.

View File

@@ -1,15 +1,17 @@
#ifndef BASESTRUCT_H
#define BASESTRUCT_H
#include <vector>
#include <deque>
#include <QVector>
//#include <deque>
#include <QPoint>
#include <QString>
#include <QPixmap>
#include <QPointF>
#include <QRect>
#include <QDebug>
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<QPixmap> 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<QPointF> path;//path() As Point
//float PicI;
//float Regeneration;
QVector<QPointF> path;//path() As Point
QPoint DestPnt;
// Effect Effects;
};

BIN
main.o

Binary file not shown.

View File

@@ -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!";
}

Binary file not shown.

View File

@@ -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!

Binary file not shown.

View File

@@ -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!

Binary file not shown.

View File

@@ -7,8 +7,8 @@ class towers
{
public:
towers();
deque<Tower> srcTowers;
deque<Tower> curTowers;
QVector<Tower> srcTowers;
QVector<Tower> curTowers;
void AddTower(QPointF point, int ** cells);
};

BIN
towers.o

Binary file not shown.

View File

@@ -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();
}

View File

@@ -1,9 +1,9 @@
#include <QUdpSocket>
#include <QObject>
#include <iostream>
//#include <iostream>
using std::cout;
using std::endl;
//using std::cout;
//using std::endl;
class UdpSender : public QObject
{

Binary file not shown.

View File

@@ -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!

BIN
wavetrace

Binary file not shown.