hm.... new global restruct... i think it last!
This commit is contained in:
311
Makefile
Normal file
311
Makefile
Normal file
@@ -0,0 +1,311 @@
|
||||
#############################################################################
|
||||
# Makefile for building: aliendefender
|
||||
# Generated by qmake (2.01a) (Qt 4.6.2) on: ?? ???? 28 22:43:44 2010
|
||||
# Project: aliendefender.pro
|
||||
# Template: app
|
||||
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro
|
||||
#############################################################################
|
||||
|
||||
####### Compiler, tools and options
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
|
||||
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
||||
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
||||
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
|
||||
LINK = g++
|
||||
LFLAGS =
|
||||
LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
QMAKE = /usr/bin/qmake-qt4
|
||||
TAR = tar -cf
|
||||
COMPRESS = gzip -9f
|
||||
COPY = cp -f
|
||||
SED = sed
|
||||
COPY_FILE = $(COPY)
|
||||
COPY_DIR = $(COPY) -r
|
||||
STRIP = strip
|
||||
INSTALL_FILE = install -m 644 -p
|
||||
INSTALL_DIR = $(COPY_DIR)
|
||||
INSTALL_PROGRAM = install -m 755 -p
|
||||
DEL_FILE = rm -f
|
||||
SYMLINK = ln -f -s
|
||||
DEL_DIR = rmdir
|
||||
MOVE = mv -f
|
||||
CHK_DIR_EXISTS= test -d
|
||||
MKDIR = mkdir -p
|
||||
|
||||
####### Output directory
|
||||
|
||||
OBJECTS_DIR = ./
|
||||
|
||||
####### Files
|
||||
|
||||
SOURCES = map.cpp \
|
||||
game_data.cpp \
|
||||
aliens.cpp \
|
||||
towers.cpp \
|
||||
main.cpp \
|
||||
splashes.cpp \
|
||||
adcore.cpp moc_map.cpp \
|
||||
moc_game_data.cpp \
|
||||
moc_aliens.cpp \
|
||||
moc_towers.cpp \
|
||||
moc_splashes.cpp \
|
||||
moc_adcore.cpp
|
||||
OBJECTS = map.o \
|
||||
game_data.o \
|
||||
aliens.o \
|
||||
towers.o \
|
||||
main.o \
|
||||
splashes.o \
|
||||
adcore.o \
|
||||
moc_map.o \
|
||||
moc_game_data.o \
|
||||
moc_aliens.o \
|
||||
moc_towers.o \
|
||||
moc_splashes.o \
|
||||
moc_adcore.o
|
||||
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
||||
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||
/usr/share/qt4/mkspecs/qconfig.pri \
|
||||
/usr/share/qt4/mkspecs/features/qt_functions.prf \
|
||||
/usr/share/qt4/mkspecs/features/qt_config.prf \
|
||||
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/share/qt4/mkspecs/features/default_pre.prf \
|
||||
/usr/share/qt4/mkspecs/features/debug.prf \
|
||||
/usr/share/qt4/mkspecs/features/default_post.prf \
|
||||
/usr/share/qt4/mkspecs/features/warn_on.prf \
|
||||
/usr/share/qt4/mkspecs/features/qt.prf \
|
||||
/usr/share/qt4/mkspecs/features/unix/thread.prf \
|
||||
/usr/share/qt4/mkspecs/features/moc.prf \
|
||||
/usr/share/qt4/mkspecs/features/resources.prf \
|
||||
/usr/share/qt4/mkspecs/features/uic.prf \
|
||||
/usr/share/qt4/mkspecs/features/yacc.prf \
|
||||
/usr/share/qt4/mkspecs/features/lex.prf \
|
||||
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
|
||||
aliendefender.pro
|
||||
QMAKE_TARGET = aliendefender
|
||||
DESTDIR =
|
||||
TARGET = aliendefender
|
||||
|
||||
first: all
|
||||
####### Implicit rules
|
||||
|
||||
.SUFFIXES: .o .c .cpp .cc .cxx .C
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cc.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.C.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
####### Build rules
|
||||
|
||||
all: Makefile $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
|
||||
|
||||
Makefile: aliendefender.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
|
||||
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||
/usr/share/qt4/mkspecs/qconfig.pri \
|
||||
/usr/share/qt4/mkspecs/features/qt_functions.prf \
|
||||
/usr/share/qt4/mkspecs/features/qt_config.prf \
|
||||
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/share/qt4/mkspecs/features/default_pre.prf \
|
||||
/usr/share/qt4/mkspecs/features/debug.prf \
|
||||
/usr/share/qt4/mkspecs/features/default_post.prf \
|
||||
/usr/share/qt4/mkspecs/features/warn_on.prf \
|
||||
/usr/share/qt4/mkspecs/features/qt.prf \
|
||||
/usr/share/qt4/mkspecs/features/unix/thread.prf \
|
||||
/usr/share/qt4/mkspecs/features/moc.prf \
|
||||
/usr/share/qt4/mkspecs/features/resources.prf \
|
||||
/usr/share/qt4/mkspecs/features/uic.prf \
|
||||
/usr/share/qt4/mkspecs/features/yacc.prf \
|
||||
/usr/share/qt4/mkspecs/features/lex.prf \
|
||||
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
|
||||
/usr/lib/libQtGui.prl \
|
||||
/usr/lib/libQtCore.prl
|
||||
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro
|
||||
/usr/share/qt4/mkspecs/common/g++.conf:
|
||||
/usr/share/qt4/mkspecs/common/unix.conf:
|
||||
/usr/share/qt4/mkspecs/common/linux.conf:
|
||||
/usr/share/qt4/mkspecs/qconfig.pri:
|
||||
/usr/share/qt4/mkspecs/features/qt_functions.prf:
|
||||
/usr/share/qt4/mkspecs/features/qt_config.prf:
|
||||
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
|
||||
/usr/share/qt4/mkspecs/features/default_pre.prf:
|
||||
/usr/share/qt4/mkspecs/features/debug.prf:
|
||||
/usr/share/qt4/mkspecs/features/default_post.prf:
|
||||
/usr/share/qt4/mkspecs/features/warn_on.prf:
|
||||
/usr/share/qt4/mkspecs/features/qt.prf:
|
||||
/usr/share/qt4/mkspecs/features/unix/thread.prf:
|
||||
/usr/share/qt4/mkspecs/features/moc.prf:
|
||||
/usr/share/qt4/mkspecs/features/resources.prf:
|
||||
/usr/share/qt4/mkspecs/features/uic.prf:
|
||||
/usr/share/qt4/mkspecs/features/yacc.prf:
|
||||
/usr/share/qt4/mkspecs/features/lex.prf:
|
||||
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
|
||||
/usr/lib/libQtGui.prl:
|
||||
/usr/lib/libQtCore.prl:
|
||||
qmake: FORCE
|
||||
@$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile aliendefender.pro
|
||||
|
||||
dist:
|
||||
@$(CHK_DIR_EXISTS) .tmp/aliendefender1.0.0 || $(MKDIR) .tmp/aliendefender1.0.0
|
||||
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/aliendefender1.0.0/ && $(COPY_FILE) --parents base_types.h map.h game_data.h aliens.h towers.h splashes.h adcore.h .tmp/aliendefender1.0.0/ && $(COPY_FILE) --parents map.cpp game_data.cpp aliens.cpp towers.cpp main.cpp splashes.cpp adcore.cpp .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
|
||||
-$(DEL_FILE) $(OBJECTS)
|
||||
-$(DEL_FILE) *~ core *.core
|
||||
|
||||
|
||||
####### Sub-libraries
|
||||
|
||||
distclean: clean
|
||||
-$(DEL_FILE) $(TARGET)
|
||||
-$(DEL_FILE) Makefile
|
||||
|
||||
|
||||
mocclean: compiler_moc_header_clean compiler_moc_source_clean
|
||||
|
||||
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
|
||||
|
||||
compiler_moc_header_make_all: moc_map.cpp moc_game_data.cpp moc_aliens.cpp moc_towers.cpp moc_splashes.cpp moc_adcore.cpp
|
||||
compiler_moc_header_clean:
|
||||
-$(DEL_FILE) moc_map.cpp moc_game_data.cpp moc_aliens.cpp moc_towers.cpp moc_splashes.cpp moc_adcore.cpp
|
||||
moc_map.cpp: base_types.h \
|
||||
map.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) map.h -o moc_map.cpp
|
||||
|
||||
moc_game_data.cpp: map.h \
|
||||
base_types.h \
|
||||
game_data.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) game_data.h -o moc_game_data.cpp
|
||||
|
||||
moc_aliens.cpp: game_data.h \
|
||||
map.h \
|
||||
base_types.h \
|
||||
aliens.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) aliens.h -o moc_aliens.cpp
|
||||
|
||||
moc_towers.cpp: game_data.h \
|
||||
map.h \
|
||||
base_types.h \
|
||||
towers.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) towers.h -o moc_towers.cpp
|
||||
|
||||
moc_splashes.cpp: game_data.h \
|
||||
map.h \
|
||||
base_types.h \
|
||||
splashes.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) splashes.h -o moc_splashes.cpp
|
||||
|
||||
moc_adcore.cpp: aliens.h \
|
||||
game_data.h \
|
||||
map.h \
|
||||
base_types.h \
|
||||
towers.h \
|
||||
splashes.h \
|
||||
adcore.h
|
||||
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) adcore.h -o moc_adcore.cpp
|
||||
|
||||
compiler_rcc_make_all:
|
||||
compiler_rcc_clean:
|
||||
compiler_image_collection_make_all: qmake_image_collection.cpp
|
||||
compiler_image_collection_clean:
|
||||
-$(DEL_FILE) qmake_image_collection.cpp
|
||||
compiler_moc_source_make_all:
|
||||
compiler_moc_source_clean:
|
||||
compiler_uic_make_all:
|
||||
compiler_uic_clean:
|
||||
compiler_yacc_decl_make_all:
|
||||
compiler_yacc_decl_clean:
|
||||
compiler_yacc_impl_make_all:
|
||||
compiler_yacc_impl_clean:
|
||||
compiler_lex_make_all:
|
||||
compiler_lex_clean:
|
||||
compiler_clean: compiler_moc_header_clean
|
||||
|
||||
####### Compile
|
||||
|
||||
map.o: map.cpp map.h \
|
||||
base_types.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o map.o map.cpp
|
||||
|
||||
game_data.o: game_data.cpp game_data.h \
|
||||
map.h \
|
||||
base_types.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o game_data.o game_data.cpp
|
||||
|
||||
aliens.o: aliens.cpp aliens.h \
|
||||
game_data.h \
|
||||
map.h \
|
||||
base_types.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o aliens.o aliens.cpp
|
||||
|
||||
towers.o: towers.cpp towers.h \
|
||||
game_data.h \
|
||||
map.h \
|
||||
base_types.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o towers.o towers.cpp
|
||||
|
||||
main.o: main.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
|
||||
|
||||
splashes.o: splashes.cpp splashes.h \
|
||||
game_data.h \
|
||||
map.h \
|
||||
base_types.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o splashes.o splashes.cpp
|
||||
|
||||
adcore.o: adcore.cpp adcore.h \
|
||||
aliens.h \
|
||||
game_data.h \
|
||||
map.h \
|
||||
base_types.h \
|
||||
towers.h \
|
||||
splashes.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o adcore.o adcore.cpp
|
||||
|
||||
moc_map.o: moc_map.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_map.o moc_map.cpp
|
||||
|
||||
moc_game_data.o: moc_game_data.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_game_data.o moc_game_data.cpp
|
||||
|
||||
moc_aliens.o: moc_aliens.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_aliens.o moc_aliens.cpp
|
||||
|
||||
moc_towers.o: moc_towers.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_towers.o moc_towers.cpp
|
||||
|
||||
moc_splashes.o: moc_splashes.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_splashes.o moc_splashes.cpp
|
||||
|
||||
moc_adcore.o: moc_adcore.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_adcore.o moc_adcore.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install: FORCE
|
||||
|
||||
uninstall: FORCE
|
||||
|
||||
FORCE:
|
||||
|
||||
20
adcore.cpp
Normal file
20
adcore.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "adcore.h"
|
||||
|
||||
adCore::adCore(QObject *parent) :
|
||||
QThread(parent)
|
||||
{
|
||||
step = 0;
|
||||
admap = new Map(1,QSize(100,100));
|
||||
addata = new Game_Data(admap);
|
||||
adaliens = new Aliens(addata);
|
||||
adtowers = new Towers(addata);
|
||||
adsplashes = new Splashes(addata);
|
||||
}
|
||||
|
||||
void adCore::next()
|
||||
{
|
||||
adtowers->update();
|
||||
adsplashes->update();
|
||||
adaliens->update();
|
||||
step++;
|
||||
}
|
||||
30
adcore.h
Normal file
30
adcore.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef ADCORE_H
|
||||
#define ADCORE_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QObject>
|
||||
|
||||
#include "aliens.h"
|
||||
#include "towers.h"
|
||||
#include "splashes.h"
|
||||
|
||||
class adCore : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit adCore(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void next();
|
||||
private:
|
||||
Map *admap;
|
||||
Game_Data *addata;
|
||||
Aliens *adaliens;
|
||||
Towers *adtowers;
|
||||
Splashes *adsplashes;
|
||||
int step;
|
||||
};
|
||||
|
||||
#endif // ADCORE_H
|
||||
300
alien.cpp
300
alien.cpp
@@ -1,300 +0,0 @@
|
||||
#include "alien.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Alien::Alien(games *parent, float alienspeed)
|
||||
{
|
||||
game = parent;
|
||||
Speed = alienspeed;
|
||||
TmpCells = new int*[game->size.width()];
|
||||
for (int i = 0; i < game->size.width(); i++)
|
||||
TmpCells[i] = new int[game->size.height()];
|
||||
position = game->start*game->cellsize;
|
||||
path.clear();
|
||||
PicIndex = 0;
|
||||
RecreatePath();
|
||||
}
|
||||
|
||||
|
||||
bool Alien::RecreatePath()
|
||||
{
|
||||
for (int i = 0; i < game->size.width(); i++)
|
||||
{
|
||||
for (int j = 0; j < game->size.height(); j++)
|
||||
{
|
||||
if (game->Cells[i][j] < 0 ) TmpCells[i][j] = -1;
|
||||
else TmpCells[i][j] = 0;
|
||||
}
|
||||
}
|
||||
QPointF tp;
|
||||
QPoint start;
|
||||
QVector<QPoint> srcPath;
|
||||
QVector<QPointF> tmpPath;
|
||||
PathIndex = 1;
|
||||
start.setX(qRound(position.x()/(float)game->cellsize));
|
||||
start.setY(qRound(position.y()/(float)game->cellsize));
|
||||
if (game->Cells[start.x()][start.y()] < 0) return false;
|
||||
srcPath = InvWaveTrace(game->finish,WaveTrace(start,game->finish));
|
||||
for (int i=0; i<srcPath.size();i++)
|
||||
{
|
||||
game->Cells[srcPath.at(i).x()][srcPath.at(i).y()] = 5;
|
||||
tmpPath.push_back(QPointF(srcPath.at(i)));
|
||||
}
|
||||
srcPath.clear();
|
||||
//qDebug() << tmpPath.size();
|
||||
if (!tmpPath.isEmpty())
|
||||
{
|
||||
for (int j=0; j<4; j++)
|
||||
{
|
||||
path.clear();
|
||||
tp = tmpPath.at(0);
|
||||
path.push_back(tp);
|
||||
for (int i = 0; i < tmpPath.size() - 1; i++)
|
||||
{
|
||||
//if (j > 1) path.push_back(tmpPath[i]);
|
||||
tp.setX((tmpPath.at(i).x() + tmpPath.at(i + 1).x()) / 2.0);
|
||||
tp.setY((tmpPath.at(i).y() + tmpPath.at(i + 1).y()) / 2.0);
|
||||
path.push_back(tp);
|
||||
}
|
||||
tp = tmpPath.at(tmpPath.size() - 1);
|
||||
path.push_back(tp);
|
||||
tmpPath = path;
|
||||
}
|
||||
tmpPath.clear();
|
||||
if (path.size() > 10)
|
||||
{
|
||||
path.remove(1);
|
||||
path.remove(1);
|
||||
path.remove(path.size()-2);
|
||||
path.remove(path.size()-2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Alien::update()
|
||||
{
|
||||
float tmpdx,tmpdy,angl,arctg = 0;
|
||||
tmpdx = position.x() - path.at(PathIndex).x()*game->cellsize;
|
||||
tmpdy = position.y() - path.at(PathIndex).y()*game->cellsize;
|
||||
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*Speed*game->cellsize)
|
||||
{
|
||||
PathIndex++;
|
||||
if (PathIndex >= path.size()) return false;
|
||||
/*{
|
||||
PathIndex = 0;
|
||||
position = game->start*game->cellsize;
|
||||
}*/
|
||||
tmpdx = position.x() - path.at(PathIndex).x()*game->cellsize;
|
||||
tmpdy = position.y() - path.at(PathIndex).y()*game->cellsize;
|
||||
//qDebug() << "next";
|
||||
}
|
||||
arctg = std::atan(tmpdx/tmpdy);
|
||||
if (tmpdy < 0) arctg=arctg+3.1416f;
|
||||
angl = 180.0f*(-arctg)/3.1416f;
|
||||
/*if (PathIndex > 1)
|
||||
{
|
||||
if ((Position.angle-angl < -5 || Position.angle-angl > 5) && angl < 175 && angl > -175)
|
||||
{
|
||||
if (angl > Position.angle) Position.angle += 5;
|
||||
else Position.angle -= 5;
|
||||
}
|
||||
else Position.angle = angl;
|
||||
}
|
||||
else*/ angle = angl;
|
||||
//qDebug() << "[" << PathIndex << ";" << PicIndex << "]" << "angle:" << Position.angle << "arctg:" << arctg << "Pos:" << Position.pnt;
|
||||
position.setX(position.x()
|
||||
-Speed*(float)game->cellsize*std::sin(arctg));
|
||||
position.setY(position.y()
|
||||
-Speed*(float)game->cellsize*std::cos(arctg));
|
||||
PicIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Alien::WaveTrace(QPoint start, QPoint finish)
|
||||
{
|
||||
bool stop = false;
|
||||
int step = 2;
|
||||
QPoint cp, tp;
|
||||
QRect fr(0, 0, game->size.width(), game->size.height());
|
||||
QVector<QPoint> 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.at(i);
|
||||
if (cp == finish) {
|
||||
TmpCells[cp.x()][cp.y()] = step;
|
||||
//qDebug() << "trace done!";
|
||||
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() << "trace false";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
QVector<QPoint> Alien::InvWaveTrace(QPoint finish, int cnt)
|
||||
{
|
||||
QPoint wp, Ppnt;
|
||||
QVector<QPoint> alpath;
|
||||
if (cnt < 2) return 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 < game->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 < game->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;
|
||||
}
|
||||
44
alien.h
44
alien.h
@@ -1,44 +0,0 @@
|
||||
#ifndef ALIEN_H
|
||||
#define ALIEN_H
|
||||
|
||||
#include "games.h"
|
||||
|
||||
class Alien
|
||||
{
|
||||
public:
|
||||
Alien(games *parent, float alienspeed = 0.1);
|
||||
bool RecreatePath();
|
||||
//bool testTrace() {return (WaveTrace(data->start,data->finish) > 0);}
|
||||
void setPos(QPointF pos) {position = pos;}
|
||||
bool update();
|
||||
void resetIndexPic() {PicIndex = 0;}
|
||||
QPointF Pos() const {return position;}
|
||||
float Angl() const {return angle;}
|
||||
int indexPix() const {return PicIndex;}
|
||||
QVector<QPointF> path;
|
||||
private:
|
||||
int ** TmpCells;
|
||||
games *game;
|
||||
QPointF position;
|
||||
float angle;
|
||||
//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;
|
||||
|
||||
int WaveTrace(QPoint start, QPoint finish);
|
||||
QVector<QPoint> InvWaveTrace(QPoint finish, int cnt);
|
||||
};
|
||||
|
||||
#endif // ALIEN_H
|
||||
@@ -1,26 +1,15 @@
|
||||
# -------------------------------------------------
|
||||
# Project created by QtCreator 2009-08-17T19:38:55
|
||||
# -------------------------------------------------
|
||||
QT += network \
|
||||
opengl
|
||||
TARGET = aliendefender
|
||||
TEMPLATE = app
|
||||
SOURCES += main.cpp \
|
||||
mainwindow.cpp \
|
||||
aliens.cpp \
|
||||
udpsender.cpp \
|
||||
towers.cpp \
|
||||
map.cpp \
|
||||
games.cpp \
|
||||
alien.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
aliens.h \
|
||||
basestruct.h \
|
||||
udpsender.h \
|
||||
towers.h \
|
||||
HEADERS += base_types.h \
|
||||
map.h \
|
||||
games.h \
|
||||
alien.h \
|
||||
uwidget.h
|
||||
FORMS += mainwindow.ui
|
||||
game_data.h \
|
||||
aliens.h \
|
||||
towers.h \
|
||||
splashes.h \
|
||||
adcore.h
|
||||
SOURCES += map.cpp \
|
||||
game_data.cpp \
|
||||
aliens.cpp \
|
||||
towers.cpp \
|
||||
main.cpp \
|
||||
splashes.cpp \
|
||||
adcore.cpp
|
||||
RESOURCES += images.qrc
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>RunConfiguration0-BaseEnvironmentBase</variable>
|
||||
<value type="int">2</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-CommandLineArguments</variable>
|
||||
<valuelist type="QVariantList"/>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-ProFile</variable>
|
||||
<value type="QString" >wavetrace.pro</value>
|
||||
<value type="QString">aliendefender.pro</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-RunConfiguration.name</variable>
|
||||
@@ -26,47 +30,23 @@
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UserSetName</variable>
|
||||
<value type="bool" >true</value>
|
||||
<value type="bool">false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UserSetWorkingDirectory</variable>
|
||||
<value type="bool">false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UserWorkingDirectory</variable>
|
||||
<value type="QString"></value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-type</variable>
|
||||
<value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-CommandLineArguments</variable>
|
||||
<valuelist type="QVariantList" />
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-ProFile</variable>
|
||||
<value type="QString" >aliendefender.pro</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-RunConfiguration.name</variable>
|
||||
<value type="QString" >aliendefender</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-UseDyldImageSuffix</variable>
|
||||
<value type="bool" >false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-UseTerminal</variable>
|
||||
<value type="bool" >false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-UserEnvironmentChanges</variable>
|
||||
<valuelist type="QVariantList" />
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-UserSetName</variable>
|
||||
<value type="bool" >false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration1-type</variable>
|
||||
<value type="QString" >Qt4ProjectManager.Qt4RunConfiguration</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>activeRunConfiguration</variable>
|
||||
<value type="int" >1</value>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>activebuildconfiguration</variable>
|
||||
@@ -77,10 +57,8 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<value key="QtVersionId" type="int">0</value>
|
||||
<value key="ToolChain" type="int" >2</value>
|
||||
<value key="addQDumper" type="" ></value>
|
||||
<value key="ToolChain" type="int">0</value>
|
||||
<value key="buildConfiguration" type="int">2</value>
|
||||
<value key="buildDirectory" type="QString" >/home/andrey/documents/sm11/Alien Defender/ad</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
@@ -88,8 +66,6 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||
<value key="QtVersionId" type="int">0</value>
|
||||
<value key="ToolChain" type="int" >2</value>
|
||||
<value key="addQDumper" type="" ></value>
|
||||
<value key="buildConfiguration" type="int">0</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
@@ -98,52 +74,47 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||
<value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-rwgGTf2llu,guid=47f9f0046990c9c4983a622a4b6c11df</value>
|
||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-p5HnkClUWv,guid=600e78a10ff64ffb1ced7c414c4c6498</value>
|
||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
||||
<value type="QString" >DESKTOP_STARTUP_ID=</value>
|
||||
<value type="QString">DISPLAY=:0.0</value>
|
||||
<value type="QString">GDMSESSION=gnome</value>
|
||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
||||
<value type="QString" >GNOME_KEYRING_SOCKET=/tmp/keyring-cqyv3T/socket</value>
|
||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-wgH6gj</value>
|
||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||
<value type="QString" >GTK_RC_FILES=/etc/gtk/gtkrc:/home/andrey/.gtkrc-1.2-gnome2</value>
|
||||
<value type="QString">HOME=/home/andrey</value>
|
||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
||||
<value type="QString" >LANGUAGE=</value>
|
||||
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
|
||||
<value type="QString">LOGNAME=andrey</value>
|
||||
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
|
||||
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
|
||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
||||
<value type="QString">PWD=/home/andrey</value>
|
||||
<value type="QString" >QTDIR=/usr</value>
|
||||
<value type="QString" >SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1283,unix/buull-eeePC:/tmp/.ICE-unix/1283</value>
|
||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1203,unix/buull-eeePC:/tmp/.ICE-unix/1203</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString" >SPEECHD_PORT=7560</value>
|
||||
<value type="QString" >SSH_AGENT_PID=1356</value>
|
||||
<value type="QString" >SSH_AUTH_SOCK=/tmp/keyring-cqyv3T/socket.ssh</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1245</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-wgH6gj/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString" >XAUTHORITY=/var/run/gdm/auth-for-andrey-FKbzYa/database</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-MPPKxH/database</value>
|
||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
||||
<value type="QString" >XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1265373654.150132-179730100</value>
|
||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1280074903.597291-1238668786</value>
|
||||
</valuelist>
|
||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||
<value type="QString" >/home/andrey/projects/aliendefender/aliendefender.pro</value>
|
||||
<value type="QString">/home/andrey/aliendefender/aliendefender.pro</value>
|
||||
<value type="QString">-spec</value>
|
||||
<value type="QString" >/usr/share/qt4/mkspecs/linux-g++</value>
|
||||
<value type="QString">linux-g++</value>
|
||||
<value type="QString">-r</value>
|
||||
<value type="QString" >CONFIG+=debug_and_release</value>
|
||||
<value type="QString" >-Wall</value>
|
||||
<value type="QString">CONFIG+=debug</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
|
||||
<value key="abstractProcess.enabled" type="bool">false</value>
|
||||
<value key="abstractProcess.workingDirectory" type="QString" >/home/andrey/projects/aliendefender</value>
|
||||
<value key="buildConfiguration" type="" ></value>
|
||||
<valuelist key="qmakeArgs" type="QVariantList" >
|
||||
<value type="QString" >-Wall</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/aliendefender</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
@@ -151,97 +122,50 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||
<value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-rwgGTf2llu,guid=47f9f0046990c9c4983a622a4b6c11df</value>
|
||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-p5HnkClUWv,guid=600e78a10ff64ffb1ced7c414c4c6498</value>
|
||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
||||
<value type="QString" >DESKTOP_STARTUP_ID=</value>
|
||||
<value type="QString">DISPLAY=:0.0</value>
|
||||
<value type="QString">GDMSESSION=gnome</value>
|
||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
||||
<value type="QString" >GNOME_KEYRING_SOCKET=/tmp/keyring-cqyv3T/socket</value>
|
||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-wgH6gj</value>
|
||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||
<value type="QString" >GTK_RC_FILES=/etc/gtk/gtkrc:/home/andrey/.gtkrc-1.2-gnome2</value>
|
||||
<value type="QString">HOME=/home/andrey</value>
|
||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
||||
<value type="QString" >LANGUAGE=</value>
|
||||
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
|
||||
<value type="QString">LOGNAME=andrey</value>
|
||||
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
|
||||
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
|
||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
||||
<value type="QString">PWD=/home/andrey</value>
|
||||
<value type="QString" >QTDIR=/usr</value>
|
||||
<value type="QString" >SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1283,unix/buull-eeePC:/tmp/.ICE-unix/1283</value>
|
||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1203,unix/buull-eeePC:/tmp/.ICE-unix/1203</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString" >SPEECHD_PORT=7560</value>
|
||||
<value type="QString" >SSH_AGENT_PID=1356</value>
|
||||
<value type="QString" >SSH_AUTH_SOCK=/tmp/keyring-cqyv3T/socket.ssh</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1245</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-wgH6gj/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString" >XAUTHORITY=/var/run/gdm/auth-for-andrey-FKbzYa/database</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-MPPKxH/database</value>
|
||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
||||
<value type="QString" >XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1265373654.150132-179730100</value>
|
||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1280074903.597291-1238668786</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
|
||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||
<value type="QString" >-j3</value>
|
||||
<value type="QString">-w</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
|
||||
<value key="abstractProcess.enabled" type="bool">true</value>
|
||||
<value key="abstractProcess.workingDirectory" type="QString" >/home/andrey/projects/aliendefender</value>
|
||||
<valuelist key="makeargs" type="QVariantList" >
|
||||
<value type="QString" >-j3</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/aliendefender</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList" >
|
||||
<value type="QString" >ALLUSERSPROFILE=C:\Documents and Settings\All Users</value>
|
||||
<value type="QString" >APPDATA=C:\Documents and Settings\Andrey\Application Data</value>
|
||||
<value type="QString" >COMMONPROGRAMFILES=C:\Program Files\Common Files</value>
|
||||
<value type="QString" >COMPUTERNAME=COMP</value>
|
||||
<value type="QString" >COMSPEC=C:\WINDOWS\system32\cmd.exe</value>
|
||||
<value type="QString" >FP_NO_HOST_CHECK=NO</value>
|
||||
<value type="QString" >HOMEDRIVE=C:</value>
|
||||
<value type="QString" >HOMEPATH=\Documents and Settings\Andrey</value>
|
||||
<value type="QString" >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</value>
|
||||
<value type="QString" >LIB=C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib</value>
|
||||
<value type="QString" >LOGONSERVER=\\COMP</value>
|
||||
<value type="QString" >MSDEVDIR=C:\Program Files\Microsoft Visual Studio\Common\MSDev98</value>
|
||||
<value type="QString" >NUMBER_OF_PROCESSORS=2</value>
|
||||
<value type="QString" >OS=Windows_NT</value>
|
||||
<value type="QString" >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;C:\Program Files\OpenVPN\bin</value>
|
||||
<value type="QString" >PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH</value>
|
||||
<value type="QString" >PROCESSOR_ARCHITECTURE=x86</value>
|
||||
<value type="QString" >PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel</value>
|
||||
<value type="QString" >PROCESSOR_LEVEL=6</value>
|
||||
<value type="QString" >PROCESSOR_REVISION=1706</value>
|
||||
<value type="QString" >PROGRAMFILES=C:\Program Files</value>
|
||||
<value type="QString" >QTDIR=D:/Qt/2010.01/qt</value>
|
||||
<value type="QString" >SESSIONNAME=Console</value>
|
||||
<value type="QString" >SYSTEMDRIVE=C:</value>
|
||||
<value type="QString" >SYSTEMROOT=C:\WINDOWS</value>
|
||||
<value type="QString" >TEMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp</value>
|
||||
<value type="QString" >TMP=C:\DOCUME~1\Andrey\LOCALS~1\Temp</value>
|
||||
<value type="QString" >USERDOMAIN=COMP</value>
|
||||
<value type="QString" >USERNAME=Andrey</value>
|
||||
<value type="QString" >USERPROFILE=C:\Documents and Settings\Andrey</value>
|
||||
<value type="QString" >VS90COMNTOOLS=D:\Programming\Microsoft Visual Studio 9.0\Common7\Tools\</value>
|
||||
<value type="QString" >VXIPNPPATH=C:\Program Files\IVI Foundation\VISA\</value>
|
||||
<value type="QString" >WINDIR=C:\WINDOWS</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.IgnoreReturnValue" type="bool" >true</value>
|
||||
<valuelist key="abstractProcess.arguments" type="QVariantList" >
|
||||
<value type="QString" >clean</value>
|
||||
<value type="QString" >-w</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.command" type="QString" >D:/Qt/2010.01/mingw/bin/mingw32-make.exe</value>
|
||||
<value key="abstractProcess.enabled" type="bool" >true</value>
|
||||
<value key="abstractProcess.workingDirectory" type="QString" >C:/aliendefender</value>
|
||||
<value key="cleanConfig" type="bool">true</value>
|
||||
<valuelist key="makeargs" type="QVariantList">
|
||||
<value type="QString">clean</value>
|
||||
@@ -252,7 +176,6 @@
|
||||
<variable>buildconfiguration-Release-buildstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||
<value key="buildConfiguration" type="" ></value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
@@ -309,7 +232,7 @@
|
||||
</data>
|
||||
<data>
|
||||
<variable>defaultFileEncoding</variable>
|
||||
<value type="QByteArray" >UTF-8</value>
|
||||
<value type="QByteArray">System</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>project</variable>
|
||||
|
||||
100
aliens.cpp
100
aliens.cpp
@@ -1,105 +1,13 @@
|
||||
#include "aliens.h"
|
||||
|
||||
Aliens::Aliens(games *parent)
|
||||
Aliens::Aliens(Game_Data *gamedata, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
game = parent;
|
||||
int x = loadPixmaps();
|
||||
if (x > 0) qDebug() << "Found" << x << "alien pictures";
|
||||
else qDebug() << "ERROR alien pictures not found!!";
|
||||
testAlien = new Alien(game);
|
||||
GameData = gamedata;
|
||||
}
|
||||
|
||||
|
||||
bool Aliens::AddAlien()
|
||||
void Aliens::update()
|
||||
{
|
||||
curAliens.push_back(new Alien(game,0.2));
|
||||
return !curAliens.isEmpty();
|
||||
}
|
||||
|
||||
/*
|
||||
void Aliens::clearAliens()
|
||||
{
|
||||
curAliens.clear();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bool Aliens::retrace()
|
||||
{
|
||||
for (int i = 0; i < game->size.width(); i++)
|
||||
{
|
||||
for (int j = 0; j < game->size.height(); j++)
|
||||
{
|
||||
if (game->Cells[i][j] == 5) game->Cells[i][j]=0;
|
||||
}
|
||||
}
|
||||
if (!testAlien->RecreatePath()) return false;
|
||||
for (int i=0; i < curAliens.size(); i ++)
|
||||
if (!curAliens.at(i)->RecreatePath()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Aliens::loadPixmaps()
|
||||
{
|
||||
QString str;
|
||||
QPixmap tmpAlPixmap;
|
||||
int i=1;
|
||||
str.setNum(i);
|
||||
while (i != 0) {
|
||||
str.setNum(i);
|
||||
tmpAlPixmap.load(":/aliens/images/Aliens/Al_00_" + str + ".png");
|
||||
if (!tmpAlPixmap.isNull()) {
|
||||
AlienPix.push_back(tmpAlPixmap);
|
||||
tmpAlPixmap = 0;
|
||||
i++;
|
||||
}
|
||||
else i = 0;
|
||||
}
|
||||
return AlienPix.size();
|
||||
}
|
||||
|
||||
|
||||
void Aliens::drawAliens()
|
||||
{
|
||||
int n=0;
|
||||
while (n < curAliens.size())
|
||||
{
|
||||
if (!curAliens.at(n)->update()) DelAlien(n);
|
||||
else
|
||||
{
|
||||
if (curAliens.at(n)->indexPix() >= AlienPix.size())
|
||||
curAliens.at(n)->resetIndexPic();
|
||||
n++;
|
||||
}
|
||||
}
|
||||
QPainter painter(game->buff);
|
||||
QPen pen(QColor(80,200,100));
|
||||
QBrush brush(QColor(230,10,10),Qt::SolidPattern);
|
||||
painter.setPen(pen);
|
||||
painter.setBrush(brush);
|
||||
painter.drawPixmap(0,0,*game->background);
|
||||
for (int i=0; i < curAliens.size(); i ++)
|
||||
{
|
||||
/*for (int j = 0; j < curAliens.at(i)->path.size(); j++)
|
||||
painter.drawEllipse(curAliens.at(i)->path.at(j).x()*game->cellsize +4,
|
||||
curAliens.at(i)->path.at(j).y()*game->cellsize +4,
|
||||
game->cellsize - 8,
|
||||
game->cellsize - 8);*/
|
||||
painter.save();
|
||||
painter.translate(curAliens.at(i)->Pos().x()+game->cellsize/2,
|
||||
curAliens.at(i)->Pos().y()+game->cellsize/2);
|
||||
painter.rotate(curAliens.at(i)->Angl());
|
||||
painter.drawPixmap(-game->cellsize, -game->cellsize,
|
||||
game->cellsize*2, game->cellsize*2,
|
||||
AlienPix[curAliens.at(i)->indexPix()]);
|
||||
painter.restore();
|
||||
}
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
void Aliens::DelAlien(int index)
|
||||
{
|
||||
curAliens.remove(index);
|
||||
}
|
||||
|
||||
36
aliens.h
36
aliens.h
@@ -1,27 +1,31 @@
|
||||
#ifndef ALIENS_H
|
||||
#define ALIENS_H
|
||||
|
||||
#include "alien.h"
|
||||
#include <QObject>
|
||||
|
||||
class Aliens
|
||||
#include "game_data.h"
|
||||
|
||||
|
||||
class Aliens : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Aliens(games *parent);
|
||||
bool AddAlien();
|
||||
explicit Aliens(Game_Data * gamedata, QObject *parent = 0);
|
||||
void AddAlien(int srcId);
|
||||
void DelAlienById(int Id);
|
||||
void DelAlien(int index);
|
||||
void drawAliens();
|
||||
bool retrace();
|
||||
int size() const {return curAliens.size();}
|
||||
//void clearAliens();
|
||||
Alien * alienAt(int index) const {return curAliens.at(index);}
|
||||
void retrace();
|
||||
void nextWave();
|
||||
void update();
|
||||
int size() const {return GameData->curAliens.size();}
|
||||
signals:
|
||||
void AlienFinish();
|
||||
public slots:
|
||||
//void getDamage(float dmg);
|
||||
private:
|
||||
games * game;
|
||||
Alien * testAlien;
|
||||
QVector<Alien*> srcAliens;
|
||||
QVector<Alien*> curAliens;
|
||||
QVector<QPixmap> AlienPix;
|
||||
|
||||
int loadPixmaps();
|
||||
Game_Data * GameData;
|
||||
QPointF globStart;
|
||||
QPointF globFinish;
|
||||
};
|
||||
|
||||
#endif // ALIENS_H
|
||||
|
||||
55
base_types.h
Normal file
55
base_types.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef BASE_TYPES_H
|
||||
#define BASE_TYPES_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QVector>
|
||||
|
||||
struct Alien
|
||||
{
|
||||
int Id;
|
||||
int type;
|
||||
QPointF pos;
|
||||
float angle; // -180 .. 180
|
||||
float speed; // cells per thick (speed=1 is 60cells by 1 sec for 60fps e.g.)
|
||||
float health;
|
||||
QPoint finish;
|
||||
QVector <QPointF> path;
|
||||
unsigned int gold;
|
||||
};
|
||||
|
||||
|
||||
struct Tower
|
||||
{
|
||||
int Id;
|
||||
int type;
|
||||
int AlienId; // aim alien
|
||||
QPoint pos; // not QPointF because tower fixed on grid
|
||||
float angle; // -180 .. 180
|
||||
float range;
|
||||
float speed; // shots per thick (e.g. speed=1 is 60 shots by 1sec for 60fps e.g. )
|
||||
};
|
||||
|
||||
|
||||
struct Splash
|
||||
{
|
||||
int Id;
|
||||
int type;
|
||||
int TowerId; // parent tower
|
||||
int AlienId; // aim alien (different from tower.AlienId)
|
||||
int lifetime; // in msec
|
||||
float radius;
|
||||
QPointF pos;
|
||||
};
|
||||
|
||||
|
||||
struct wave
|
||||
{
|
||||
int Id;
|
||||
QVector <int> types; // some types of aliens (e.g. 2 fly and 3 grount in one wave)
|
||||
QVector <int> counts; // count aliens of each type
|
||||
int wait_time; // time in sec
|
||||
unsigned int gold;
|
||||
};
|
||||
|
||||
|
||||
#endif // BASE_TYPES_H
|
||||
91
basestruct.h
91
basestruct.h
@@ -1,91 +0,0 @@
|
||||
#ifndef BASESTRUCT_H
|
||||
#define BASESTRUCT_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
|
||||
|
||||
/*
|
||||
struct FPVector
|
||||
{
|
||||
QPointF pnt;
|
||||
float angle;
|
||||
};
|
||||
*/
|
||||
|
||||
/*
|
||||
struct GameData
|
||||
{
|
||||
QSize size;
|
||||
QPoint start;
|
||||
QPoint finish;
|
||||
QPixmap * buff;
|
||||
int cellsize;
|
||||
int ** Cells;
|
||||
};
|
||||
*/
|
||||
|
||||
/*struct Effect
|
||||
{
|
||||
float Health;
|
||||
float Speed;
|
||||
int Armor;
|
||||
int CntHealth;
|
||||
int CntSpeed;
|
||||
int CntArmor;
|
||||
};*/
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
/*
|
||||
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;
|
||||
};
|
||||
|
||||
*/
|
||||
#endif // BASESTRUCT_H
|
||||
Binary file not shown.
7
game_data.cpp
Normal file
7
game_data.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "game_data.h"
|
||||
|
||||
Game_Data::Game_Data(Map *mapp, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
map = mapp;
|
||||
}
|
||||
30
game_data.h
Normal file
30
game_data.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef GAME_DATA_H
|
||||
#define GAME_DATA_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "map.h"
|
||||
|
||||
class Game_Data : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Game_Data(Map * map, QObject *parent = 0);
|
||||
QVector <Alien> srcAliens;
|
||||
QVector <Alien> curAliens;
|
||||
QVector <Tower> srcTowers;
|
||||
QVector <Tower> curTowers;
|
||||
QVector <Splash> srcSplashes;
|
||||
QVector <Splash> curSplashes;
|
||||
QVector <wave> waves;
|
||||
Map * map;
|
||||
unsigned long int adMoney;
|
||||
int selectAlienId;
|
||||
int curWave;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // GAME_DATA_H
|
||||
19
games.cpp
19
games.cpp
@@ -1,19 +0,0 @@
|
||||
#include "games.h"
|
||||
|
||||
games::games(QSize formsize, QPoint startpnt, QPoint finishpnt, int sizeofcell)
|
||||
{
|
||||
buff = new QPixmap(formsize);
|
||||
background = new QPixmap(formsize);
|
||||
cellsize = sizeofcell;
|
||||
size = formsize/cellsize;
|
||||
start = startpnt/cellsize;
|
||||
finish = finishpnt/cellsize;
|
||||
Cells = new int*[size.width()];
|
||||
for (int i = 0; i < size.width(); i++) {
|
||||
Cells[i] = new int[size.height()];
|
||||
for (int j = 0; j < size.height(); j++) Cells[i][j] = 0;
|
||||
}
|
||||
Cells[start.x()][start.y()] = 10;
|
||||
Cells[finish.x()][finish.y()] = 10;
|
||||
qDebug() << start << finish;
|
||||
}
|
||||
19
games.h
19
games.h
@@ -1,19 +0,0 @@
|
||||
#ifndef GAMES_H
|
||||
#define GAMES_H
|
||||
|
||||
#include "basestruct.h"
|
||||
|
||||
class games
|
||||
{
|
||||
public:
|
||||
games(QSize formsize, QPoint startpnt, QPoint finishpnt, int sizeofcell = 16);
|
||||
QSize size;
|
||||
QPoint start;
|
||||
QPoint finish;
|
||||
QPixmap * buff;
|
||||
QPixmap * background;
|
||||
int cellsize;
|
||||
int ** Cells;
|
||||
};
|
||||
|
||||
#endif // GAMES_H
|
||||
8
main.cpp
8
main.cpp
@@ -1,11 +1,11 @@
|
||||
#include <QDebug>
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "adcore.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
adCore core;
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
w.resize(666,444);
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
174
mainwindow.cpp
174
mainwindow.cpp
@@ -1,174 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
qDebug() << "Load START!";
|
||||
ui->setupUi(this);
|
||||
wd = new USWidget(ui->frGame);
|
||||
//ui->frGame->addWidget(wd);
|
||||
wd->resize(ui->frGame->size());
|
||||
connect(wd,SIGNAL(paintEvent(QPaintEvent*)),this,SLOT(paint(QPaintEvent*)));
|
||||
connect(wd,SIGNAL(mouseMoveEvent(QMouseEvent*)),
|
||||
this,SLOT(mouse_move(QMouseEvent*)));
|
||||
connect(wd,SIGNAL(mousePressEvent(QMouseEvent*)),
|
||||
this,SLOT(mouse_press(QMouseEvent*)));
|
||||
//sndr = new UdpSender("127.0.0.1",10101);
|
||||
//sndr->connectSend("hellow");
|
||||
int cellsize = 16;
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(ADrender()));
|
||||
qDebug() << wd->size();
|
||||
GameMain = new games(wd->size(),QPoint(0,wd->height()/2),
|
||||
QPoint(wd->width()-cellsize,wd->height()/2),
|
||||
cellsize);
|
||||
maliens = new Aliens(GameMain);
|
||||
maliens->AddAlien();
|
||||
mmap = new map(GameMain);
|
||||
mmap->clear();
|
||||
mmap->drawgrid();
|
||||
mtowers = new towers(GameMain);
|
||||
//this->setGeometry(100,100,this->width(),this->height());
|
||||
timer->start(50);
|
||||
mousebt = 0;
|
||||
qDebug() << "Load DONE!";
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
int cellsize = 16;
|
||||
wd->resize(ui->frGame->size());
|
||||
delete mtowers;
|
||||
delete mmap;
|
||||
delete maliens;
|
||||
delete GameMain;
|
||||
GameMain = new games(wd->size(),QPoint(0,wd->height()/2),
|
||||
QPoint(wd->width()-cellsize,wd->height()/2),
|
||||
cellsize);
|
||||
maliens = new Aliens(GameMain);
|
||||
maliens->AddAlien();
|
||||
mmap = new map(GameMain);
|
||||
mmap->clear();
|
||||
mmap->drawgrid();
|
||||
mtowers = new towers(GameMain);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ADrender()
|
||||
{
|
||||
QString str;
|
||||
maliens->drawAliens();
|
||||
str.setNum(maliens->size());
|
||||
ui->lbCount->setText(QString::fromUtf8("Количество: ")+str+QString::fromUtf8(" шт"));
|
||||
wd->repaint();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::paint(QPaintEvent* )
|
||||
{
|
||||
QPainter painter;
|
||||
painter.begin(wd);
|
||||
painter.drawPixmap(0,0,*GameMain->buff);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mouse_move(QMouseEvent *event)
|
||||
{
|
||||
if (mousebt == 1) ClearCell(event->pos());
|
||||
if (mousebt == 2) SetCell(event->pos());
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mouse_press(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
ClearCell(event->pos());
|
||||
mousebt = 1;
|
||||
return;
|
||||
}
|
||||
if(event->button() == Qt::LeftButton) {
|
||||
SetCell(event->pos());
|
||||
mousebt = 2;
|
||||
return;
|
||||
}
|
||||
mousebt = 0;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::SetCell(QPoint pos)
|
||||
{
|
||||
bool trace = false;
|
||||
QPoint cp;
|
||||
QRect wdrect(0, 0, (wd->width()/GameMain->cellsize)*GameMain->cellsize,
|
||||
(wd->height()/GameMain->cellsize)*GameMain->cellsize);
|
||||
if (wdrect.contains(pos)) {
|
||||
cp.setX(pos.x()/GameMain->cellsize);
|
||||
cp.setY(pos.y()/GameMain->cellsize);
|
||||
//qDebug() << cp << GameMain->Cells[cp.x()][cp.y()];
|
||||
if (GameMain->Cells[cp.x()][cp.y()] == 10) return;
|
||||
mtowers->drawcell(cp);
|
||||
if (GameMain->Cells[cp.x()][cp.y()] == 5) trace = true;
|
||||
GameMain->Cells[cp.x()][cp.y()] = - 1;
|
||||
if (trace)
|
||||
if (!maliens->retrace()) ClearCell(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ClearCell(QPoint pos)
|
||||
{
|
||||
QPoint cp;
|
||||
QRect wdrect(0, 0, (wd->width()/GameMain->cellsize)*GameMain->cellsize,
|
||||
(wd->height()/GameMain->cellsize)*GameMain->cellsize);
|
||||
if (wdrect.contains(pos)) {
|
||||
cp.setX(pos.x()/GameMain->cellsize);
|
||||
cp.setY(pos.y()/GameMain->cellsize);
|
||||
if (GameMain->Cells[cp.x()][cp.y()] == 10) return;
|
||||
GameMain->Cells[cp.x()][cp.y()] = 0;
|
||||
mtowers->clearcell(cp);
|
||||
maliens->retrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent * e)
|
||||
{
|
||||
//qDebug() << e->key();
|
||||
switch(e->key()) {
|
||||
case 65:
|
||||
maliens->AddAlien();
|
||||
break;
|
||||
case 68:
|
||||
if (maliens->size() > 0) maliens->DelAlien(maliens->size()-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete mtowers;
|
||||
delete mmap;
|
||||
delete maliens;
|
||||
delete GameMain;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_3_clicked()
|
||||
{
|
||||
if (maliens->size() > 0) maliens->DelAlien(maliens->size()-1);
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
maliens->AddAlien();
|
||||
}
|
||||
54
mainwindow.h
54
mainwindow.h
@@ -1,54 +0,0 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include "aliens.h"
|
||||
#include "map.h"
|
||||
#include "towers.h"
|
||||
#include "udpsender.h"
|
||||
#include "uwidget.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
public slots:
|
||||
void ADrender();
|
||||
void paint(QPaintEvent*);
|
||||
void mouse_move(QMouseEvent *e);
|
||||
void mouse_press(QMouseEvent *e);
|
||||
private:
|
||||
void SetCell(QPoint pos);
|
||||
void ClearCell(QPoint pos);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
Ui::MainWindow *ui;
|
||||
Aliens * maliens;
|
||||
map * mmap;
|
||||
towers * mtowers;
|
||||
USWidget * wd;
|
||||
//UdpSender * sndr;
|
||||
games * GameMain;
|
||||
QTimer *timer;
|
||||
int mousebt;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_2_clicked();
|
||||
void on_pushButton_3_clicked();
|
||||
void on_pushButton_clicked();
|
||||
};
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frGame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Добавить</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>Удалить</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbCount">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Выход</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
30
map.cpp
30
map.cpp
@@ -1,31 +1,7 @@
|
||||
#include "map.h"
|
||||
|
||||
|
||||
map::map(games *parent)
|
||||
Map::Map(int Id, QSize size, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
game = parent;
|
||||
}
|
||||
|
||||
|
||||
void map::clear()
|
||||
{
|
||||
QPainter painter(game->background);
|
||||
QPen pen(QColor(150,150,150));
|
||||
painter.setPen(pen);
|
||||
painter.fillRect(game->background->rect(),QColor(150,150,150));
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
void map::drawgrid()
|
||||
{
|
||||
int i;
|
||||
QPainter painter(game->background);
|
||||
QPen pen(QColor(100,100,100));
|
||||
painter.setPen(pen);
|
||||
for (i = 0; i < game->background->width()/game->cellsize; i++)
|
||||
painter.drawLine(i*game->cellsize,0,i*game->cellsize,game->background->height());
|
||||
for (i = 0; i < game->background->height()/game->cellsize; i++)
|
||||
painter.drawLine(0,i*game->cellsize,game->background->width(),i*game->cellsize);
|
||||
painter.end();
|
||||
mapId=Id;
|
||||
}
|
||||
|
||||
26
map.h
26
map.h
@@ -1,16 +1,30 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include "games.h"
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
#include <QVector>
|
||||
#include <QPointF>
|
||||
|
||||
class map
|
||||
#include "base_types.h"
|
||||
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
map(games *parent);
|
||||
void clear();
|
||||
void drawgrid();
|
||||
explicit Map(int Id, QSize size, QObject *parent = 0);
|
||||
int Id() const {return mapId;}
|
||||
int addTowerOnMap();
|
||||
int delTowerOnMap();
|
||||
QVector <QPointF> CreatePath(QPoint start, QPoint finish);
|
||||
signals:
|
||||
void RecreateAlienPath();
|
||||
public slots:
|
||||
|
||||
private:
|
||||
games * game;
|
||||
int **Cells;
|
||||
int mapId;
|
||||
};
|
||||
|
||||
#endif // MAP_H
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
INPUT(
|
||||
./debug\main.o
|
||||
./debug\mainwindow.o
|
||||
./debug\adpainter.o
|
||||
./debug\aliens.o
|
||||
./debug\udpsender.o
|
||||
./debug\towers.o
|
||||
./debug\map.o
|
||||
./debug\games.o
|
||||
./debug\alien.o
|
||||
./debug\moc_mainwindow.o
|
||||
./debug\moc_udpsender.o
|
||||
./debug\qrc_images.o
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
INPUT(
|
||||
./release\main.o
|
||||
./release\mainwindow.o
|
||||
./release\adpainter.o
|
||||
./release\aliens.o
|
||||
./release\udpsender.o
|
||||
./release\towers.o
|
||||
./release\map.o
|
||||
./release\games.o
|
||||
./release\alien.o
|
||||
./release\moc_mainwindow.o
|
||||
./release\moc_udpsender.o
|
||||
./release\qrc_images.o
|
||||
);
|
||||
Binary file not shown.
13
splashes.cpp
Normal file
13
splashes.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "splashes.h"
|
||||
|
||||
Splashes::Splashes(Game_Data *gamedata, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
GameData = gamedata;
|
||||
}
|
||||
|
||||
|
||||
void Splashes::update()
|
||||
{
|
||||
|
||||
}
|
||||
27
splashes.h
Normal file
27
splashes.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef SPLASHES_H
|
||||
#define SPLASHES_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "game_data.h"
|
||||
|
||||
class Splashes : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Splashes(Game_Data * gamedata, QObject *parent = 0);
|
||||
void AddSplash(int srcId);
|
||||
void DelSplashById(int Id);
|
||||
void DelSplash(int index);
|
||||
void update();
|
||||
int size() const {return GameData->curSplashes.size();}
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
Game_Data *GameData;
|
||||
};
|
||||
|
||||
#endif // SPLASHES_H
|
||||
32
towers.cpp
32
towers.cpp
@@ -1,37 +1,13 @@
|
||||
#include "towers.h"
|
||||
|
||||
towers::towers(games *parent)
|
||||
Towers::Towers(Game_Data *gamedata, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
game = parent;
|
||||
GameData = gamedata;
|
||||
}
|
||||
|
||||
|
||||
void towers::drawcell(QPoint pnt)
|
||||
{
|
||||
QPainter painter(game->background);
|
||||
QPen pen(QColor(0,0,0));
|
||||
QBrush brush(QColor(0,0,0),Qt::SolidPattern);
|
||||
painter.setPen(pen);
|
||||
painter.setBrush(brush);
|
||||
painter.drawRect(pnt.x()*game->cellsize+1,pnt.y()*game->cellsize+1,game->cellsize - 2, game->cellsize - 2);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
void towers::clearcell(QPoint pnt)
|
||||
{
|
||||
QPainter painter(game->background);
|
||||
QPen pen(QColor::fromRgb(qRgb(150,150,150)));
|
||||
QBrush brush(QColor(150,150,150),Qt::SolidPattern);
|
||||
painter.setPen(pen);
|
||||
painter.setBrush(brush);
|
||||
painter.drawRect(pnt.x()*game->cellsize+1,pnt.y()*game->cellsize+1,game->cellsize - 2, game->cellsize - 2);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
/*
|
||||
void towers::AddTower(QPoint point, int type)
|
||||
void Towers::update()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
25
towers.h
25
towers.h
@@ -1,19 +1,26 @@
|
||||
#ifndef TOWERS_H
|
||||
#define TOWERS_H
|
||||
|
||||
#include "games.h"
|
||||
#include <QObject>
|
||||
|
||||
class towers
|
||||
#include "game_data.h"
|
||||
|
||||
class Towers : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
towers(games *parent);
|
||||
//QVector<Tower> srcTowers;
|
||||
//QVector<Tower> curTowers;
|
||||
//void AddTower(QPoint point, int type);
|
||||
void drawcell(QPoint pnt);
|
||||
void clearcell(QPoint pnt);
|
||||
explicit Towers(Game_Data * gamedata, QObject *parent = 0);
|
||||
void AddTower(int srcId);
|
||||
void DelTowerById(int Id);
|
||||
void DelTower(int index);
|
||||
void update();
|
||||
int size() const {return GameData->curTowers.size();}
|
||||
signals:
|
||||
//void Shot();
|
||||
public slots:
|
||||
|
||||
private:
|
||||
games * game;
|
||||
Game_Data * GameData;
|
||||
};
|
||||
|
||||
#endif // TOWERS_H
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "udpsender.h"
|
||||
|
||||
|
||||
UdpSender::UdpSender(QString IP, quint16 Port)
|
||||
{
|
||||
sock = new QUdpSocket();
|
||||
qDebug() << sock->state();
|
||||
//cout << sock->socketDescriptor() << endl;
|
||||
//qDebug() << sock->socketDescriptor();
|
||||
addr = QHostAddress(IP);
|
||||
port = Port;
|
||||
connect(sock, SIGNAL(readyRead()),this, SLOT(slotRead()));
|
||||
}
|
||||
|
||||
|
||||
UdpSender::~UdpSender()
|
||||
{
|
||||
sock->close();
|
||||
delete sock;
|
||||
}
|
||||
|
||||
|
||||
void UdpSender::slotRead()
|
||||
{
|
||||
QString s;
|
||||
QByteArray * recdata = new QByteArray();
|
||||
*recdata = sock->readAll();
|
||||
s = *recdata;
|
||||
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();
|
||||
emit dataResieved(recdata);
|
||||
}
|
||||
|
||||
|
||||
void UdpSender::connectSend(QString s)
|
||||
{
|
||||
sz = s.length();
|
||||
sock->connectToHost(addr,port);
|
||||
qDebug() << sock->error();
|
||||
qDebug() << sock->state();
|
||||
qDebug() << sock->socketDescriptor();
|
||||
if (sock->write(s.toUtf8())>0) qDebug() << "writen!";
|
||||
}
|
||||
22
udpsender.h
22
udpsender.h
@@ -1,22 +0,0 @@
|
||||
#include <QUdpSocket>
|
||||
#include <QObject>
|
||||
|
||||
class UdpSender : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QString recstr;
|
||||
UdpSender(QString IP, quint16 Port);
|
||||
~UdpSender();
|
||||
void connectSend(QString s);
|
||||
public slots:
|
||||
void slotRead();
|
||||
private:
|
||||
QUdpSocket * sock;
|
||||
QHostAddress addr;
|
||||
quint16 port;
|
||||
quint32 sz;
|
||||
QByteArray * senddata;
|
||||
signals:
|
||||
void dataResieved(QByteArray * data);
|
||||
};
|
||||
57
uwidget.h
57
uwidget.h
@@ -1,57 +0,0 @@
|
||||
#include <QGLWidget>
|
||||
#include <QWidget>
|
||||
|
||||
class UGLWidget: public QGLWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UGLWidget(QWidget * parent = 0): QGLWidget(parent) {setGeometry(0, 0, 0, 0);}
|
||||
signals:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
void dragEnterEvent(QDragEnterEvent * e);
|
||||
void dragLeaveEvent(QDragLeaveEvent * e);
|
||||
void dragMoveEvent(QDragMoveEvent * e);
|
||||
void dropEvent(QDropEvent * e);
|
||||
void enterEvent(QEvent * e);
|
||||
void hideEvent(QHideEvent * e);
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
void keyReleaseEvent(QKeyEvent * e);
|
||||
void leaveEvent(QEvent * e);
|
||||
void mouseDoubleClickEvent(QMouseEvent * e);
|
||||
void mouseMoveEvent(QMouseEvent * e);
|
||||
void mousePressEvent(QMouseEvent * e);
|
||||
void mouseReleaseEvent(QMouseEvent * e);
|
||||
void moveEvent(QMoveEvent * e);
|
||||
void glDraw();
|
||||
void paintGL();
|
||||
void resizeEvent(QResizeEvent * e);
|
||||
void showEvent(QShowEvent * e);
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
void paintEvent(QPaintEvent * e);
|
||||
};
|
||||
|
||||
|
||||
class USWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
USWidget(QWidget * parent = 0): QWidget(parent) {setGeometry(0, 0, 0, 0);}
|
||||
signals:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
void dragEnterEvent(QDragEnterEvent * e);
|
||||
void dragLeaveEvent(QDragLeaveEvent * e);
|
||||
void dragMoveEvent(QDragMoveEvent * e);
|
||||
void dropEvent(QDropEvent * e);
|
||||
void enterEvent(QEvent * e);
|
||||
void hideEvent(QHideEvent * e);
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
void keyReleaseEvent(QKeyEvent * e);
|
||||
void leaveEvent(QEvent * e);
|
||||
void mouseDoubleClickEvent(QMouseEvent * e);
|
||||
void mouseMoveEvent(QMouseEvent * e);
|
||||
void mousePressEvent(QMouseEvent * e);
|
||||
void mouseReleaseEvent(QMouseEvent * e);
|
||||
void moveEvent(QMoveEvent * e);
|
||||
void resizeEvent(QResizeEvent * e);
|
||||
void showEvent(QShowEvent * e);
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
void paintEvent(QPaintEvent * e);
|
||||
};
|
||||
Reference in New Issue
Block a user