few optimization and find aim for towers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "ad_graphics.h"
|
||||
#include <QGLWidget>
|
||||
|
||||
|
||||
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
|
||||
@@ -10,7 +11,9 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
scene = new QGraphicsScene();
|
||||
setScene(scene);
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
//setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
//setDragMode(RubberBandDrag);
|
||||
//gsw = new QGraphicsWidget();
|
||||
//scene->addWidget(new QPushButton());
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ HEADERS += base_types.h \
|
||||
player.h \
|
||||
loader.h \
|
||||
animation.h \
|
||||
ad_graphics.h
|
||||
ad_graphics.h \
|
||||
graphicsalien.h
|
||||
SOURCES += map.cpp \
|
||||
game_data.cpp \
|
||||
aliens.cpp \
|
||||
@@ -19,10 +20,10 @@ SOURCES += map.cpp \
|
||||
player.cpp \
|
||||
loader.cpp \
|
||||
animation.cpp \
|
||||
ad_graphics.cpp
|
||||
ad_graphics.cpp \
|
||||
graphicsalien.cpp
|
||||
RESOURCES += images.qrc
|
||||
OTHER_FILES += \
|
||||
data.xml \
|
||||
OTHER_FILES += data.xml \
|
||||
schema.xml \
|
||||
data2.xml
|
||||
QT += core \
|
||||
|
||||
@@ -1,113 +1,214 @@
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<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">aliendefender.pro</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-RunConfiguration.name</variable>
|
||||
<value type="QString">aliendefender</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UseDyldImageSuffix</variable>
|
||||
<value type="bool">false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UseTerminal</variable>
|
||||
<value type="bool">false</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UserEnvironmentChanges</variable>
|
||||
<valuelist type="QVariantList"/>
|
||||
</data>
|
||||
<data>
|
||||
<variable>RunConfiguration0-UserSetName</variable>
|
||||
<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>activeRunConfiguration</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<variable>activebuildconfiguration</variable>
|
||||
<value type="QString">Debug</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildConfiguration-Debug</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="EditorConfiguration.Codec" type="QByteArray">System</value>
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<value key="QtVersionId" type="int">2</value>
|
||||
<value key="ToolChain" type="int">0</value>
|
||||
<value key="buildConfiguration" type="int">2</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<variable>buildconfiguration-Debug-buildstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Настольный компьютер</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
|
||||
<value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
|
||||
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
|
||||
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
|
||||
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
|
||||
</valuemap>
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
|
||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
|
||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
|
||||
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
||||
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Отладка</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/build-AD</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
||||
</valuemap>
|
||||
<valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
|
||||
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
|
||||
</valuemap>
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
|
||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
|
||||
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
|
||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
|
||||
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
||||
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Релиз</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender-build-desktop</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
|
||||
<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
|
||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">aliendefender</value>
|
||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
|
||||
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">aliendefender.pro</value>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
|
||||
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">true</value>
|
||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString">C:\Users\Andrey\Desktop\aliendefender</value>
|
||||
</valuemap>
|
||||
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
|
||||
<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-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f</value>
|
||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||
<value type="QString">DESKTOP_SESSION=gnome</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_CONTROL=/tmp/keyring-U899U4</value>
|
||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||
<value type="QString">HOME=/home/andrey</value>
|
||||
<value type="QString">LANG=ru_RU.UTF-8</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/share/qt4</value>
|
||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1236,unix/buull-eeePC:/tmp/.ICE-unix/1236</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1270</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-U899U4/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-6T6AjI/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-1283024543.354844-1194058895</value>
|
||||
</valuelist>
|
||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||
<value type="QString">/home/andrey/AD/aliendefender/aliendefender.pro</value>
|
||||
<value type="QString">-spec</value>
|
||||
<value type="QString">linux-g++</value>
|
||||
<value type="QString">-r</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/AD/aliendefender</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
<variable>buildconfiguration-Debug-buildstep1</variable>
|
||||
<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-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f</value>
|
||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||
<value type="QString">DESKTOP_SESSION=gnome</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_CONTROL=/tmp/keyring-U899U4</value>
|
||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||
<value type="QString">HOME=/home/andrey</value>
|
||||
<value type="QString">LANG=ru_RU.UTF-8</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/share/qt4</value>
|
||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1236,unix/buull-eeePC:/tmp/.ICE-unix/1236</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1270</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-U899U4/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-6T6AjI/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-1283024543.354844-1194058895</value>
|
||||
</valuelist>
|
||||
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
|
||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||
<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/AD/aliendefender</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">4</value>
|
||||
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<value key="cleanConfig" type="bool">true</value>
|
||||
<valuelist key="makeargs" type="QVariantList">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildconfigurations</variable>
|
||||
<valuelist type="QVariantList">
|
||||
<value type="QString">Debug</value>
|
||||
</valuelist>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
||||
<value key="mkspec" type="QString"></value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildstep1</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildsteps</variable>
|
||||
<valuelist type="QVariantList">
|
||||
<value type="QString">trolltech.qt4projectmanager.qmake</value>
|
||||
<value type="QString">trolltech.qt4projectmanager.make</value>
|
||||
</valuelist>
|
||||
</data>
|
||||
<data>
|
||||
<variable>cleanstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
||||
<value key="clean" type="bool">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>cleansteps</variable>
|
||||
<valuelist type="QVariantList">
|
||||
<value type="QString">trolltech.qt4projectmanager.make</value>
|
||||
</valuelist>
|
||||
</data>
|
||||
<data>
|
||||
<variable>defaultFileEncoding</variable>
|
||||
<value type="QByteArray">System</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>project</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
||||
48
aliens.cpp
48
aliens.cpp
@@ -17,7 +17,7 @@ void Aliens::addAlien(int srcId)
|
||||
return;
|
||||
}
|
||||
AlienType al;// = gameData->srcAliens.at(srcId);
|
||||
al.Id = nextId;
|
||||
al.id = nextId;
|
||||
al.src = srcId;
|
||||
al.finish = gameData->map->finishs().at(qrand()%gameData->map->finishs().size());
|
||||
al.pos = QPointF(gameData->map->starts().at(qrand()%gameData->map->starts().size()));
|
||||
@@ -30,7 +30,7 @@ void Aliens::addAlien(int srcId)
|
||||
al.speed = gameData->srcAliens.at(srcId).speed;
|
||||
al.imgType = gameData->srcAliens.at(srcId).imgType;
|
||||
//gameData->map->printMap();
|
||||
gameData->curAliens.insert(al.Id,al);
|
||||
gameData->curAliens.insert(al.id,al);
|
||||
nextId++;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ void Aliens::retrace(bool * OK)
|
||||
{
|
||||
qDebug("re-trace!");
|
||||
gameData->map->removeAliensPath();
|
||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
gameData->curAliens.values()[i].path = gameData->map->createPath(gameData->curAliens.values()[i].pos.toPoint(),gameData->curAliens.values()[i].finish);
|
||||
gameData->curAliens.values()[i].pathIndex = 1;
|
||||
if (gameData->curAliens.values()[i].path.isEmpty()) *OK = false;
|
||||
(*i).path = gameData->map->createPath((*i).pos.toPoint(),(*i).finish);
|
||||
(*i).pathIndex = 1;
|
||||
if ((*i).path.isEmpty()) *OK = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,33 +57,33 @@ void Aliens::delAlien(int Id)
|
||||
void Aliens::update()
|
||||
{
|
||||
QList <int> missIndex;
|
||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
AlienType al = gameData->curAliens.values().at(i);
|
||||
AlienType al = (*i);
|
||||
//qDebug() << i;
|
||||
//if (al.health < 0) emit AlienKill();
|
||||
float tmpdx,tmpdy,angl,arctg = 0;
|
||||
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
|
||||
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
||||
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*al.speed)
|
||||
tmpdx = (*i).pos.x() - (*i).path.at((*i).pathIndex).x();
|
||||
tmpdy = (*i).pos.y() - (*i).path.at((*i).pathIndex).y();
|
||||
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*(*i).speed)
|
||||
{
|
||||
al.pathIndex++;
|
||||
if (al.pathIndex >= al.path.size())
|
||||
(*i).pathIndex++;
|
||||
if ((*i).pathIndex >= (*i).path.size())
|
||||
{
|
||||
qDebug() << tr("Missing aliens = %1!").arg(gameData->missingAliens);
|
||||
missIndex.push_back(al.Id);
|
||||
missIndex.push_back((*i).id);
|
||||
break;
|
||||
}
|
||||
/*{
|
||||
PathIndex = 0;
|
||||
position = game->start*game->cellsize;
|
||||
}*/
|
||||
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
|
||||
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
||||
tmpdx = (*i).pos.x() - (*i).path.at((*i).pathIndex).x();
|
||||
tmpdy = (*i).pos.y() - (*i).path.at((*i).pathIndex).y();
|
||||
//qDebug() << "next";
|
||||
}
|
||||
arctg = std::atan(tmpdx/tmpdy);
|
||||
if (tmpdy < 0) arctg=arctg+M_PI;
|
||||
arctg = std::atan2(tmpdx,tmpdy);
|
||||
//if (tmpdy < 0) arctg=arctg+M_PI;
|
||||
angl = 180.0f*(-arctg)/M_PI;
|
||||
/*if (PathIndex > 1)
|
||||
{
|
||||
@@ -95,14 +95,14 @@ void Aliens::update()
|
||||
else Position.angle = angl;
|
||||
}
|
||||
else*/
|
||||
al.angle = angl;
|
||||
(*i).angle = angl;
|
||||
//qDebug() << "[" << PathIndex << ";" << PicIndex << "]" << "angle:" << Position.angle << "arctg:" << arctg << "Pos:" << Position.pnt;
|
||||
al.pos.setX(al.pos.x()
|
||||
-al.speed*std::sin(arctg));
|
||||
al.pos.setY(al.pos.y()
|
||||
-al.speed*std::cos(arctg));
|
||||
(*i).pos.setX((*i).pos.x()
|
||||
-(*i).speed*std::sin(arctg));
|
||||
(*i).pos.setY((*i).pos.y()
|
||||
-(*i).speed*std::cos(arctg));
|
||||
//return true;
|
||||
gameData->curAliens.insert(al.Id,al);
|
||||
//gameData->curAliens.insert(al.id,al);
|
||||
//qDebug() <<"alien"<< i << " path index=" << al.pathIndex << ", pos=" << al.pos;
|
||||
}
|
||||
for (int j=0; j<missIndex.size(); j++)
|
||||
|
||||
@@ -31,7 +31,7 @@ struct srcAlienType
|
||||
|
||||
struct AlienType
|
||||
{
|
||||
int Id; // uses for QHash
|
||||
int id; // uses for QHash
|
||||
int src;
|
||||
QPointF pos;
|
||||
float angle; // -180 .. 180
|
||||
@@ -92,7 +92,7 @@ struct srcSplashType
|
||||
|
||||
struct SplashType
|
||||
{
|
||||
int Id;
|
||||
int id;
|
||||
int imgType;
|
||||
int src;
|
||||
QPoint TowerId; // parent tower (-1;-1) for null parent
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</aliens>
|
||||
<maps>
|
||||
<map width="16" imageType="1" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
|
||||
<map data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" id="2" imageType="2" width="30" height="20" name="map2" maxPlayers="1"/>
|
||||
</maps>
|
||||
<waves>
|
||||
<wave prise="100" timeout="5" id="1"/>
|
||||
@@ -23,7 +24,7 @@
|
||||
<wave prise="220" timeout="5" id="11"/>
|
||||
</waves>
|
||||
<levels>
|
||||
<level map="1" id="1" score="265630088" name="First Level"/>
|
||||
<level map="2" id="1" score="265630088" name="First Level"/>
|
||||
</levels>
|
||||
<waveParts>
|
||||
<wavePart alien="10" count="4" wave="1"/>
|
||||
|
||||
18
graphicsalien.cpp
Normal file
18
graphicsalien.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "graphicsalien.h"
|
||||
|
||||
GraphicsAlien::GraphicsAlien(QGraphicsItem *grItem) : QGraphicsItem(grItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QRectF GraphicsAlien::boundingRect()
|
||||
{
|
||||
return QRectF(0,0,10,10);
|
||||
}
|
||||
|
||||
|
||||
void GraphicsAlien::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
||||
}
|
||||
14
graphicsalien.h
Normal file
14
graphicsalien.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GRAPHICSALIEN_H
|
||||
#define GRAPHICSALIEN_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
class GraphicsAlien : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
GraphicsAlien(QGraphicsItem * grItem= 0);
|
||||
QRectF boundingRect();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
};
|
||||
|
||||
#endif // GRAPHICSALIEN_H
|
||||
14
loader.cpp
14
loader.cpp
@@ -5,6 +5,7 @@ Loader::Loader(QObject *parent) :
|
||||
{
|
||||
doc = new QDomDocument("data");
|
||||
//create();
|
||||
qDebug() << createMapExample();
|
||||
//load();
|
||||
}
|
||||
|
||||
@@ -391,10 +392,10 @@ void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, sr
|
||||
QString Loader::createMapExample()
|
||||
{
|
||||
QVector < QVector < int > > Cells;
|
||||
Cells.resize(16);
|
||||
Cells.resize(30);
|
||||
for (int i=0; i<Cells.size(); i++)
|
||||
{
|
||||
Cells[i].resize(16);
|
||||
Cells[i].resize(20);
|
||||
Cells[i][0]=Map::Wall;
|
||||
Cells[i][Cells[i].size()-1]=Map::Wall;
|
||||
}
|
||||
@@ -406,17 +407,14 @@ QString Loader::createMapExample()
|
||||
Cells[Cells.size()-1][j]=Map::Wall;
|
||||
}
|
||||
}
|
||||
for (int i=1; i<Cells.size()/2; i++)
|
||||
for (int i=1; i<Cells.size()-1; i++)
|
||||
for (int j=1; j<Cells[i].size()-1; j++)
|
||||
Cells[i][j]=Map::Player;
|
||||
for (int i=Cells.size()/2; i<Cells.size()-1; i++)
|
||||
for (int j=1; j<Cells[i].size()-1; j++)
|
||||
Cells[i][j]=Map::Player+1;
|
||||
for (int i=2; i<Cells.size()-2; i++)
|
||||
Cells[i][Cells[i].size()/2] = Map::Wall;
|
||||
Cells[Cells.size()/2][0]=Map::Start;
|
||||
Cells[0][Cells[0].size()/2]=Map::Start;
|
||||
Cells[Cells.size()/2-1][0]=Map::Start;
|
||||
Cells[Cells.size()/2][Cells[Cells.size()/2].size()-1]=Map::Finish;
|
||||
Cells[Cells.size()-1][Cells[Cells.size()-1].size()/2]=Map::Finish;
|
||||
Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Map::Finish;
|
||||
QByteArray ba;
|
||||
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -10,7 +10,7 @@ int main(int argc, char *argv[])
|
||||
QApplication a(argc, argv);
|
||||
AD_Core core;
|
||||
AD_Graphics graphics(&core);
|
||||
graphics.resize(800,600);
|
||||
graphics.resize(750,450);
|
||||
//QTimer * timer = new QTimer();
|
||||
//QObject::connect(timer,SIGNAL(timeout()),&core,SLOT(next()));
|
||||
//timer->start(100);
|
||||
|
||||
6
map.cpp
6
map.cpp
@@ -88,7 +88,7 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
return true;
|
||||
}
|
||||
if (Cells[pos.x()][pos.y()]==PlayerAlien+playerId)
|
||||
if (Cells[pos.x()][pos.y()]==AlienPath+playerId)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
bool ok=true;
|
||||
@@ -98,7 +98,7 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||
qDebug()<<"ok="<<ok;
|
||||
if (!ok)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerAlien+playerId;
|
||||
Cells[pos.x()][pos.y()]=AlienPath+playerId;
|
||||
return false;
|
||||
}
|
||||
//Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
@@ -110,7 +110,7 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||
qDebug() << *pathOK;
|
||||
if (!pathOK)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerAlien+playerId;
|
||||
Cells[pos.x()][pos.y()]=AlienPath+playerId;
|
||||
emit recreateAlienPath(pathOK);
|
||||
return false;
|
||||
}
|
||||
|
||||
3
map.h
3
map.h
@@ -11,8 +11,9 @@ Q_OBJECT
|
||||
public:
|
||||
enum CellType
|
||||
{
|
||||
Free = 0,
|
||||
Player = 1,
|
||||
PlayerAlien = 1001,
|
||||
AlienPath = 1000,
|
||||
PlayerTower = -1,
|
||||
Wall = -1000,
|
||||
Start = 9999,
|
||||
|
||||
@@ -18,7 +18,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
||||
}
|
||||
srcSplashType src = gameData->srcSplashes.at(srcId);
|
||||
SplashType spl;// = gameData->srcAliens.at(srcId);
|
||||
spl.Id = nextId;
|
||||
spl.id = nextId;
|
||||
spl.src = srcId;
|
||||
spl.TowerId = QPoint(-1,-1);
|
||||
spl.life = 0;
|
||||
@@ -39,7 +39,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
||||
trig.src = src.triggerIndexes.at(i);
|
||||
spl.triggers.push_back(trig);
|
||||
}
|
||||
gameData->curSplashes.insert(spl.Id,spl);
|
||||
gameData->curSplashes.insert(spl.id,spl);
|
||||
nextId++;
|
||||
return true;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
||||
void Splashes::addSplash(srcSplashType src, int index, TowerType tw)
|
||||
{
|
||||
SplashType spl;
|
||||
spl.Id = nextId;
|
||||
spl.id = nextId;
|
||||
spl.TowerId = tw.pos;
|
||||
if (!gameData->curAliens.contains(tw.aim))
|
||||
qFatal("Error finding splash aim! Tower has nvalid aim!");
|
||||
@@ -69,7 +69,7 @@ void Splashes::addSplash(srcSplashType src, int index, TowerType tw)
|
||||
trig.src = src.triggerIndexes.at(i);
|
||||
spl.triggers.push_back(trig);
|
||||
}
|
||||
gameData->curSplashes.insert(spl.Id,spl);
|
||||
gameData->curSplashes.insert(spl.id,spl);
|
||||
nextId++;
|
||||
}
|
||||
|
||||
|
||||
41
towers.cpp
41
towers.cpp
@@ -1,7 +1,9 @@
|
||||
#include "towers.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Towers::Towers(Game_Data *gd, QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
gameData = gd;
|
||||
}
|
||||
@@ -28,7 +30,7 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
||||
tw.build = 0;
|
||||
tw.reload = 0;
|
||||
tw.aim = -1;
|
||||
tw .oldAim = -1;
|
||||
//tw .oldAim = -1;
|
||||
if (gameData->map->addTowerOnMap(playerId,pos))
|
||||
{
|
||||
tw.pos = pos;
|
||||
@@ -48,20 +50,35 @@ void Towers::delTower(QPoint pos)
|
||||
|
||||
void Towers::update()
|
||||
{
|
||||
for (int i=0; i<gameData->curTowers.size(); i++)
|
||||
for (QHash<QPoint, TowerType>::iterator i = gameData->curTowers.begin(); i != gameData->curTowers.end(); ++i)
|
||||
{
|
||||
TowerType tw = gameData->curTowers.values().at(i);
|
||||
srcTowerType stw = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src);
|
||||
if (tw.build < stw.buildTime)
|
||||
srcTowerType stw = gameData->players.at((*i).PlayerId)->srcTowers.at((*i).src);
|
||||
if ((*i).build < stw.buildTime)
|
||||
{
|
||||
tw.build++;
|
||||
(*i).build++;
|
||||
} else {
|
||||
// TODO: finding aim alien in this place
|
||||
if (tw.reload < stw.reload)
|
||||
if (gameData->players.at((*i).PlayerId)->selectAlienId > 0)
|
||||
{
|
||||
tw.reload++;
|
||||
} else {
|
||||
emit shot(stw.splashes.at(0), 0, tw);
|
||||
AlienType al = gameData->curAliens.value(gameData->players.at((*i).PlayerId)->selectAlienId);
|
||||
float dist = (al.pos.x() - (*i).pos.x())*(al.pos.x() - (*i).pos.x()) + (al.pos.y() - (*i).pos.y())*(al.pos.y() - (*i).pos.y());
|
||||
if (dist < stw.radius) (*i).aim = al.id;
|
||||
}
|
||||
if ((*i).aim < 0)
|
||||
{
|
||||
for (QHash<int, AlienType>::iterator j = gameData->curAliens.begin(); j != gameData->curAliens.end(); ++j)
|
||||
{
|
||||
float dist = ((*j).pos.x() - (*i).pos.x())*((*j).pos.x() - (*i).pos.x()) + ((*j).pos.y() - (*i).pos.y())*((*j).pos.y() - (*i).pos.y());
|
||||
if (dist < stw.radius) (*i).aim = (*j).id;
|
||||
else (*i).aim = -1;
|
||||
}
|
||||
}
|
||||
// TODO: rotate tower to aim
|
||||
if ((*i).reload < stw.reload)
|
||||
(*i).reload++;
|
||||
else
|
||||
{
|
||||
if ((*i).aim > 0)
|
||||
emit shot(stw.splashes.at(0), 0, (*i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user