few optimization and find aim for towers
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include "ad_graphics.h"
|
#include "ad_graphics.h"
|
||||||
|
#include <QGLWidget>
|
||||||
|
|
||||||
|
|
||||||
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
|
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);
|
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
scene = new QGraphicsScene();
|
scene = new QGraphicsScene();
|
||||||
setScene(scene);
|
setScene(scene);
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||||
|
//setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
|
//setDragMode(RubberBandDrag);
|
||||||
//gsw = new QGraphicsWidget();
|
//gsw = new QGraphicsWidget();
|
||||||
//scene->addWidget(new QPushButton());
|
//scene->addWidget(new QPushButton());
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ HEADERS += base_types.h \
|
|||||||
player.h \
|
player.h \
|
||||||
loader.h \
|
loader.h \
|
||||||
animation.h \
|
animation.h \
|
||||||
ad_graphics.h
|
ad_graphics.h \
|
||||||
|
graphicsalien.h
|
||||||
SOURCES += map.cpp \
|
SOURCES += map.cpp \
|
||||||
game_data.cpp \
|
game_data.cpp \
|
||||||
aliens.cpp \
|
aliens.cpp \
|
||||||
@@ -19,10 +20,10 @@ SOURCES += map.cpp \
|
|||||||
player.cpp \
|
player.cpp \
|
||||||
loader.cpp \
|
loader.cpp \
|
||||||
animation.cpp \
|
animation.cpp \
|
||||||
ad_graphics.cpp
|
ad_graphics.cpp \
|
||||||
|
graphicsalien.cpp
|
||||||
RESOURCES += images.qrc
|
RESOURCES += images.qrc
|
||||||
OTHER_FILES += \
|
OTHER_FILES += data.xml \
|
||||||
data.xml \
|
|
||||||
schema.xml \
|
schema.xml \
|
||||||
data2.xml
|
data2.xml
|
||||||
QT += core \
|
QT += core \
|
||||||
|
|||||||
@@ -1,113 +1,214 @@
|
|||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<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>
|
<value type="int">0</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
<variable>activebuildconfiguration</variable>
|
||||||
|
<value type="QString">Debug</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>buildConfiguration-Debug</variable>
|
||||||
<valuemap type="QVariantMap">
|
<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>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
<variable>buildconfiguration-Debug-buildstep0</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Настольный компьютер</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
|
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||||
<value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
|
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f</value>
|
||||||
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
|
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||||
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
|
<value type="QString">DESKTOP_SESSION=gnome</value>
|
||||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
|
<value type="QString">DISPLAY=:0.0</value>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
|
<value type="QString">GDMSESSION=gnome</value>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
|
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
||||||
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
|
<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>
|
</valuemap>
|
||||||
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
|
</data>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
<data>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
<variable>buildconfiguration-Debug-buildstep1</variable>
|
||||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
<valuemap type="QVariantMap">
|
||||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></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>
|
</valuemap>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
|
</data>
|
||||||
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
|
<data>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Сборка</value>
|
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
<valuemap type="QVariantMap">
|
||||||
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
|
<value key="cleanConfig" type="bool">true</value>
|
||||||
|
<valuelist key="makeargs" type="QVariantList">
|
||||||
<value type="QString">clean</value>
|
<value type="QString">clean</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
|
</data>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
<data>
|
||||||
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
<variable>buildconfigurations</variable>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Отладка</value>
|
<valuelist type="QVariantList">
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
<value type="QString">Debug</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>
|
</valuelist>
|
||||||
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
</data>
|
||||||
</valuemap>
|
<data>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
|
<variable>buildstep0</variable>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
<valuemap type="QVariantMap">
|
||||||
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
||||||
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Релиз</value>
|
<value key="mkspec" 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>
|
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
<variable>buildstep1</variable>
|
||||||
<value type="int">1</value>
|
<valuemap type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
||||||
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
<variable>buildsteps</variable>
|
||||||
<value type="int">4</value>
|
<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>
|
</data>
|
||||||
</qtcreator>
|
</qtcreator>
|
||||||
|
|||||||
48
aliens.cpp
48
aliens.cpp
@@ -17,7 +17,7 @@ void Aliens::addAlien(int srcId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlienType al;// = gameData->srcAliens.at(srcId);
|
AlienType al;// = gameData->srcAliens.at(srcId);
|
||||||
al.Id = nextId;
|
al.id = nextId;
|
||||||
al.src = srcId;
|
al.src = srcId;
|
||||||
al.finish = gameData->map->finishs().at(qrand()%gameData->map->finishs().size());
|
al.finish = gameData->map->finishs().at(qrand()%gameData->map->finishs().size());
|
||||||
al.pos = QPointF(gameData->map->starts().at(qrand()%gameData->map->starts().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.speed = gameData->srcAliens.at(srcId).speed;
|
||||||
al.imgType = gameData->srcAliens.at(srcId).imgType;
|
al.imgType = gameData->srcAliens.at(srcId).imgType;
|
||||||
//gameData->map->printMap();
|
//gameData->map->printMap();
|
||||||
gameData->curAliens.insert(al.Id,al);
|
gameData->curAliens.insert(al.id,al);
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,11 +39,11 @@ void Aliens::retrace(bool * OK)
|
|||||||
{
|
{
|
||||||
qDebug("re-trace!");
|
qDebug("re-trace!");
|
||||||
gameData->map->removeAliensPath();
|
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);
|
(*i).path = gameData->map->createPath((*i).pos.toPoint(),(*i).finish);
|
||||||
gameData->curAliens.values()[i].pathIndex = 1;
|
(*i).pathIndex = 1;
|
||||||
if (gameData->curAliens.values()[i].path.isEmpty()) *OK = false;
|
if ((*i).path.isEmpty()) *OK = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,33 +57,33 @@ void Aliens::delAlien(int Id)
|
|||||||
void Aliens::update()
|
void Aliens::update()
|
||||||
{
|
{
|
||||||
QList <int> missIndex;
|
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;
|
//qDebug() << i;
|
||||||
//if (al.health < 0) emit AlienKill();
|
//if (al.health < 0) emit AlienKill();
|
||||||
float tmpdx,tmpdy,angl,arctg = 0;
|
float tmpdx,tmpdy,angl,arctg = 0;
|
||||||
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
|
tmpdx = (*i).pos.x() - (*i).path.at((*i).pathIndex).x();
|
||||||
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
tmpdy = (*i).pos.y() - (*i).path.at((*i).pathIndex).y();
|
||||||
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*al.speed)
|
while (std::sqrt(tmpdx*tmpdx +tmpdy*tmpdy) < 2*(*i).speed)
|
||||||
{
|
{
|
||||||
al.pathIndex++;
|
(*i).pathIndex++;
|
||||||
if (al.pathIndex >= al.path.size())
|
if ((*i).pathIndex >= (*i).path.size())
|
||||||
{
|
{
|
||||||
qDebug() << tr("Missing aliens = %1!").arg(gameData->missingAliens);
|
qDebug() << tr("Missing aliens = %1!").arg(gameData->missingAliens);
|
||||||
missIndex.push_back(al.Id);
|
missIndex.push_back((*i).id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*{
|
/*{
|
||||||
PathIndex = 0;
|
PathIndex = 0;
|
||||||
position = game->start*game->cellsize;
|
position = game->start*game->cellsize;
|
||||||
}*/
|
}*/
|
||||||
tmpdx = al.pos.x() - al.path.at(al.pathIndex).x();
|
tmpdx = (*i).pos.x() - (*i).path.at((*i).pathIndex).x();
|
||||||
tmpdy = al.pos.y() - al.path.at(al.pathIndex).y();
|
tmpdy = (*i).pos.y() - (*i).path.at((*i).pathIndex).y();
|
||||||
//qDebug() << "next";
|
//qDebug() << "next";
|
||||||
}
|
}
|
||||||
arctg = std::atan(tmpdx/tmpdy);
|
arctg = std::atan2(tmpdx,tmpdy);
|
||||||
if (tmpdy < 0) arctg=arctg+M_PI;
|
//if (tmpdy < 0) arctg=arctg+M_PI;
|
||||||
angl = 180.0f*(-arctg)/M_PI;
|
angl = 180.0f*(-arctg)/M_PI;
|
||||||
/*if (PathIndex > 1)
|
/*if (PathIndex > 1)
|
||||||
{
|
{
|
||||||
@@ -95,14 +95,14 @@ void Aliens::update()
|
|||||||
else Position.angle = angl;
|
else Position.angle = angl;
|
||||||
}
|
}
|
||||||
else*/
|
else*/
|
||||||
al.angle = angl;
|
(*i).angle = angl;
|
||||||
//qDebug() << "[" << PathIndex << ";" << PicIndex << "]" << "angle:" << Position.angle << "arctg:" << arctg << "Pos:" << Position.pnt;
|
//qDebug() << "[" << PathIndex << ";" << PicIndex << "]" << "angle:" << Position.angle << "arctg:" << arctg << "Pos:" << Position.pnt;
|
||||||
al.pos.setX(al.pos.x()
|
(*i).pos.setX((*i).pos.x()
|
||||||
-al.speed*std::sin(arctg));
|
-(*i).speed*std::sin(arctg));
|
||||||
al.pos.setY(al.pos.y()
|
(*i).pos.setY((*i).pos.y()
|
||||||
-al.speed*std::cos(arctg));
|
-(*i).speed*std::cos(arctg));
|
||||||
//return true;
|
//return true;
|
||||||
gameData->curAliens.insert(al.Id,al);
|
//gameData->curAliens.insert(al.id,al);
|
||||||
//qDebug() <<"alien"<< i << " path index=" << al.pathIndex << ", pos=" << al.pos;
|
//qDebug() <<"alien"<< i << " path index=" << al.pathIndex << ", pos=" << al.pos;
|
||||||
}
|
}
|
||||||
for (int j=0; j<missIndex.size(); j++)
|
for (int j=0; j<missIndex.size(); j++)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct srcAlienType
|
|||||||
|
|
||||||
struct AlienType
|
struct AlienType
|
||||||
{
|
{
|
||||||
int Id; // uses for QHash
|
int id; // uses for QHash
|
||||||
int src;
|
int src;
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
@@ -92,7 +92,7 @@ struct srcSplashType
|
|||||||
|
|
||||||
struct SplashType
|
struct SplashType
|
||||||
{
|
{
|
||||||
int Id;
|
int id;
|
||||||
int imgType;
|
int imgType;
|
||||||
int src;
|
int src;
|
||||||
QPoint TowerId; // parent tower (-1;-1) for null parent
|
QPoint TowerId; // parent tower (-1;-1) for null parent
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
</aliens>
|
</aliens>
|
||||||
<maps>
|
<maps>
|
||||||
<map width="16" imageType="1" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
|
<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>
|
</maps>
|
||||||
<waves>
|
<waves>
|
||||||
<wave prise="100" timeout="5" id="1"/>
|
<wave prise="100" timeout="5" id="1"/>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
<wave prise="220" timeout="5" id="11"/>
|
<wave prise="220" timeout="5" id="11"/>
|
||||||
</waves>
|
</waves>
|
||||||
<levels>
|
<levels>
|
||||||
<level map="1" id="1" score="265630088" name="First Level"/>
|
<level map="2" id="1" score="265630088" name="First Level"/>
|
||||||
</levels>
|
</levels>
|
||||||
<waveParts>
|
<waveParts>
|
||||||
<wavePart alien="10" count="4" wave="1"/>
|
<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");
|
doc = new QDomDocument("data");
|
||||||
//create();
|
//create();
|
||||||
|
qDebug() << createMapExample();
|
||||||
//load();
|
//load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,10 +392,10 @@ void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, sr
|
|||||||
QString Loader::createMapExample()
|
QString Loader::createMapExample()
|
||||||
{
|
{
|
||||||
QVector < QVector < int > > Cells;
|
QVector < QVector < int > > Cells;
|
||||||
Cells.resize(16);
|
Cells.resize(30);
|
||||||
for (int i=0; i<Cells.size(); i++)
|
for (int i=0; i<Cells.size(); i++)
|
||||||
{
|
{
|
||||||
Cells[i].resize(16);
|
Cells[i].resize(20);
|
||||||
Cells[i][0]=Map::Wall;
|
Cells[i][0]=Map::Wall;
|
||||||
Cells[i][Cells[i].size()-1]=Map::Wall;
|
Cells[i][Cells[i].size()-1]=Map::Wall;
|
||||||
}
|
}
|
||||||
@@ -406,17 +407,14 @@ QString Loader::createMapExample()
|
|||||||
Cells[Cells.size()-1][j]=Map::Wall;
|
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++)
|
for (int j=1; j<Cells[i].size()-1; j++)
|
||||||
Cells[i][j]=Map::Player;
|
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++)
|
for (int i=2; i<Cells.size()-2; i++)
|
||||||
Cells[i][Cells[i].size()/2] = Map::Wall;
|
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-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;
|
Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Map::Finish;
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
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);
|
QApplication a(argc, argv);
|
||||||
AD_Core core;
|
AD_Core core;
|
||||||
AD_Graphics graphics(&core);
|
AD_Graphics graphics(&core);
|
||||||
graphics.resize(800,600);
|
graphics.resize(750,450);
|
||||||
//QTimer * timer = new QTimer();
|
//QTimer * timer = new QTimer();
|
||||||
//QObject::connect(timer,SIGNAL(timeout()),&core,SLOT(next()));
|
//QObject::connect(timer,SIGNAL(timeout()),&core,SLOT(next()));
|
||||||
//timer->start(100);
|
//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;
|
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||||
return true;
|
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;
|
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||||
bool ok=true;
|
bool ok=true;
|
||||||
@@ -98,7 +98,7 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
|||||||
qDebug()<<"ok="<<ok;
|
qDebug()<<"ok="<<ok;
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
Cells[pos.x()][pos.y()]=PlayerAlien+playerId;
|
Cells[pos.x()][pos.y()]=AlienPath+playerId;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
//Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||||
@@ -110,7 +110,7 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
|||||||
qDebug() << *pathOK;
|
qDebug() << *pathOK;
|
||||||
if (!pathOK)
|
if (!pathOK)
|
||||||
{
|
{
|
||||||
Cells[pos.x()][pos.y()]=PlayerAlien+playerId;
|
Cells[pos.x()][pos.y()]=AlienPath+playerId;
|
||||||
emit recreateAlienPath(pathOK);
|
emit recreateAlienPath(pathOK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
3
map.h
3
map.h
@@ -11,8 +11,9 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
enum CellType
|
enum CellType
|
||||||
{
|
{
|
||||||
|
Free = 0,
|
||||||
Player = 1,
|
Player = 1,
|
||||||
PlayerAlien = 1001,
|
AlienPath = 1000,
|
||||||
PlayerTower = -1,
|
PlayerTower = -1,
|
||||||
Wall = -1000,
|
Wall = -1000,
|
||||||
Start = 9999,
|
Start = 9999,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
|||||||
}
|
}
|
||||||
srcSplashType src = gameData->srcSplashes.at(srcId);
|
srcSplashType src = gameData->srcSplashes.at(srcId);
|
||||||
SplashType spl;// = gameData->srcAliens.at(srcId);
|
SplashType spl;// = gameData->srcAliens.at(srcId);
|
||||||
spl.Id = nextId;
|
spl.id = nextId;
|
||||||
spl.src = srcId;
|
spl.src = srcId;
|
||||||
spl.TowerId = QPoint(-1,-1);
|
spl.TowerId = QPoint(-1,-1);
|
||||||
spl.life = 0;
|
spl.life = 0;
|
||||||
@@ -39,7 +39,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
|||||||
trig.src = src.triggerIndexes.at(i);
|
trig.src = src.triggerIndexes.at(i);
|
||||||
spl.triggers.push_back(trig);
|
spl.triggers.push_back(trig);
|
||||||
}
|
}
|
||||||
gameData->curSplashes.insert(spl.Id,spl);
|
gameData->curSplashes.insert(spl.id,spl);
|
||||||
nextId++;
|
nextId++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
|||||||
void Splashes::addSplash(srcSplashType src, int index, TowerType tw)
|
void Splashes::addSplash(srcSplashType src, int index, TowerType tw)
|
||||||
{
|
{
|
||||||
SplashType spl;
|
SplashType spl;
|
||||||
spl.Id = nextId;
|
spl.id = nextId;
|
||||||
spl.TowerId = tw.pos;
|
spl.TowerId = tw.pos;
|
||||||
if (!gameData->curAliens.contains(tw.aim))
|
if (!gameData->curAliens.contains(tw.aim))
|
||||||
qFatal("Error finding splash aim! Tower has nvalid 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);
|
trig.src = src.triggerIndexes.at(i);
|
||||||
spl.triggers.push_back(trig);
|
spl.triggers.push_back(trig);
|
||||||
}
|
}
|
||||||
gameData->curSplashes.insert(spl.Id,spl);
|
gameData->curSplashes.insert(spl.id,spl);
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
39
towers.cpp
39
towers.cpp
@@ -1,5 +1,7 @@
|
|||||||
#include "towers.h"
|
#include "towers.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
Towers::Towers(Game_Data *gd, QObject *parent) :
|
Towers::Towers(Game_Data *gd, QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -28,7 +30,7 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
|||||||
tw.build = 0;
|
tw.build = 0;
|
||||||
tw.reload = 0;
|
tw.reload = 0;
|
||||||
tw.aim = -1;
|
tw.aim = -1;
|
||||||
tw .oldAim = -1;
|
//tw .oldAim = -1;
|
||||||
if (gameData->map->addTowerOnMap(playerId,pos))
|
if (gameData->map->addTowerOnMap(playerId,pos))
|
||||||
{
|
{
|
||||||
tw.pos = pos;
|
tw.pos = pos;
|
||||||
@@ -48,20 +50,35 @@ void Towers::delTower(QPoint pos)
|
|||||||
|
|
||||||
void Towers::update()
|
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((*i).PlayerId)->srcTowers.at((*i).src);
|
||||||
srcTowerType stw = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src);
|
if ((*i).build < stw.buildTime)
|
||||||
if (tw.build < stw.buildTime)
|
|
||||||
{
|
{
|
||||||
tw.build++;
|
(*i).build++;
|
||||||
} else {
|
} else {
|
||||||
// TODO: finding aim alien in this place
|
if (gameData->players.at((*i).PlayerId)->selectAlienId > 0)
|
||||||
if (tw.reload < stw.reload)
|
|
||||||
{
|
{
|
||||||
tw.reload++;
|
AlienType al = gameData->curAliens.value(gameData->players.at((*i).PlayerId)->selectAlienId);
|
||||||
} else {
|
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());
|
||||||
emit shot(stw.splashes.at(0), 0, tw);
|
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