now is enable build and delete towers in game and improve graphic perfomance
find and correct many-many bugs
This commit is contained in:
@@ -11,11 +11,44 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
scene = new QGraphicsScene();
|
||||
setScene(scene);
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32);
|
||||
//setDragMode(RubberBandDrag);
|
||||
//gsw = new QGraphicsWidget();
|
||||
//scene->addWidget(new QPushButton());
|
||||
QPainter p(mapimg);
|
||||
for (int i=0; i<data->map->cells().size(); i++) {
|
||||
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
||||
QPen pen;
|
||||
QBrush brush;
|
||||
pen.setColor(Qt::white);
|
||||
brush.setColor(Qt::white);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
int cel = data->map->cells().at(i).at(j);
|
||||
if (cel == Map::Wall)
|
||||
{
|
||||
pen.setColor(Qt::black);
|
||||
brush.setColor(Qt::black);
|
||||
}
|
||||
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
||||
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// }
|
||||
// if (cel >= Map::PlayerAlien) {
|
||||
// pen.setColor(Qt::yellow);
|
||||
// brush.setColor(Qt::yellow);
|
||||
// }
|
||||
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
||||
{
|
||||
pen.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50));
|
||||
brush.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50));
|
||||
}
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
p.drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
||||
}
|
||||
}
|
||||
|
||||
startTimer(25);
|
||||
show();
|
||||
@@ -55,37 +88,7 @@ void AD_Graphics::timerEvent(QTimerEvent * )
|
||||
|
||||
void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
|
||||
{
|
||||
for (int i=0; i<data->map->cells().size(); i++) {
|
||||
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
||||
QPen pen;
|
||||
QBrush brush;
|
||||
pen.setColor(Qt::white);
|
||||
brush.setColor(Qt::white);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
int cel = data->map->cells().at(i).at(j);
|
||||
if (cel == Map::Wall)
|
||||
{
|
||||
pen.setColor(Qt::black);
|
||||
brush.setColor(Qt::black);
|
||||
}
|
||||
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
||||
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// }
|
||||
// if (cel >= Map::PlayerAlien) {
|
||||
// pen.setColor(Qt::yellow);
|
||||
// brush.setColor(Qt::yellow);
|
||||
// }
|
||||
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
||||
{
|
||||
pen.setColor(QColor(qAbs(cel)%255,(qAbs(cel)*100)%255,(qAbs(cel)+100)%255,50));
|
||||
brush.setColor(QColor(qAbs(cel)%255,(qAbs(cel)*100)%255,(qAbs(cel)+100)%255,50));
|
||||
}
|
||||
p->setPen(pen);
|
||||
p->setBrush(brush);
|
||||
p->drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
||||
}
|
||||
}
|
||||
p->drawImage(0,0,*mapimg);
|
||||
//qDebug() << "t:" << data->curTowers.size();
|
||||
for (QHash<QPoint, TowerType>::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ private:
|
||||
QGraphicsScene * scene;
|
||||
Game_Data * data;
|
||||
AD_Core * core;
|
||||
QImage * mapimg;
|
||||
QVector<QVector<Animation * > > images;
|
||||
//QGraphicsWidget * gsw;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ AD_Core::AD_Core(QObject *parent) :
|
||||
// adaliens->addAlien(0);
|
||||
// adaliens->AddAlien(0);
|
||||
// adaliens->AddAlien(0);
|
||||
adtowers->addTower(0,2,QPoint(22,7));
|
||||
adtowers->addTower(0,2,QPoint(15,1));
|
||||
for (int i=0; i<20;i++)
|
||||
// adtowers->addTower(0,1,QPoint(8,20-i));
|
||||
// for (int i=0; i<20; i++)
|
||||
|
||||
@@ -1,111 +1,241 @@
|
||||
<!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">0</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-Release</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"></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">Debug</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"></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 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">Release</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">Release</value>
|
||||
<value key="QtVersionId" type="int">0</value>
|
||||
<value key="buildConfiguration" type="int">0</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
<variable>buildconfiguration-Debug-buildstep0</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-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</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-4vN5uf</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/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1239</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/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-1283151906.338331-318132279</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.Updater.FileVersion</variable>
|
||||
<value type="int">4</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-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</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-4vN5uf</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/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SPEECHD_PORT=6561</value>
|
||||
<value type="QString">SSH_AGENT_PID=1239</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
|
||||
<value type="QString">USER=andrey</value>
|
||||
<value type="QString">USERNAME=andrey</value>
|
||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/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-1283151906.338331-318132279</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>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>buildconfiguration-Release-buildstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildconfiguration-Release-buildstep1</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildconfiguration-Release-cleanstep0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>buildconfigurations</variable>
|
||||
<valuelist type="QVariantList">
|
||||
<value type="QString">Debug</value>
|
||||
<value type="QString">Release</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>
|
||||
|
||||
@@ -42,13 +42,17 @@ void Aliens::addAlien(int srcId)
|
||||
|
||||
void Aliens::retrace(bool * OK)
|
||||
{
|
||||
qDebug("re-trace!");
|
||||
//qDebug("re-trace!");
|
||||
gameData->map->removeAliensPath();
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
(*i).path = gameData->map->createPath((*i).pos.toPoint(),(*i).finish);
|
||||
(*i).pathIndex = 1;
|
||||
if ((*i).path.isEmpty()) *OK = false;
|
||||
if ((*i).path.isEmpty())
|
||||
{
|
||||
*OK = false;
|
||||
qDebug("Aliens retrace = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<splash speed="0" imageType="2" lifetime="3" id="5" name="smoke"/>
|
||||
</splashes>
|
||||
<towers>
|
||||
<tower imageType="0" radius="8" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="20" id="1" name="rocket launcher 2" cost="50" expByDamage="0.04"/>
|
||||
<tower imageType="0" radius="12" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="15" id="1" name="rocket launcher 2" cost="50" expByDamage="0.04"/>
|
||||
<tower imageType="1" radius="5" expByKill="0.2" expByShot="0.1" buildTime="100" splash="3" reload="20" id="2" name="gun" cost="10" expByDamage="0.1"/>
|
||||
<tower imageType="0" radius="4" expByKill="0.1" expByShot="0.15" buildTime="200" splash="1" reload="50" id="3" name="rocket launcher" cost="30" expByDamage="0.04"/>
|
||||
</towers>
|
||||
|
||||
92
map.cpp
92
map.cpp
@@ -81,13 +81,32 @@ void Map::removeAliensPath()
|
||||
|
||||
void Map::delTowerOnMap(int playerId, QPoint pos)
|
||||
{
|
||||
bool * pathOK;
|
||||
pathOK = new bool();
|
||||
emit recreateAlienPath(pathOK);
|
||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
||||
emit recreateAlienPath(new bool());
|
||||
}
|
||||
|
||||
|
||||
bool Map::isReachable(int playerId, QPoint pos)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId;
|
||||
for (int i=0; i<Starts.size(); i++) {
|
||||
for (int j=0; j<Finishs.size(); j++) {
|
||||
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
|
||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,74 +123,21 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||
Cells[pos.x()+1][pos.y()]==Player+playerId &&
|
||||
Cells[pos.x()][pos.y()+1]==Player+playerId &&
|
||||
Cells[pos.x()+1][pos.y()+1]==Player+playerId)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId;
|
||||
for (int i=0; i<Starts.size(); i++) {
|
||||
for (int j=0; j<Finishs.size(); j++) {
|
||||
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
|
||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return isReachable(playerId,pos);
|
||||
if ((Cells[pos.x()][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()]==Player+playerId) &&
|
||||
(Cells[pos.x()+1][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()+1][pos.y()]==Player+playerId) &&
|
||||
(Cells[pos.x()][pos.y()+1]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()+1]==Player+playerId) &&
|
||||
(Cells[pos.x()+1][pos.y()+1]==AlienPath+Player+playerId || Cells[pos.x()+1][pos.y()+1]==Player+playerId))
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId;
|
||||
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId;
|
||||
for (int i=0; i<Starts.size(); i++) {
|
||||
for (int j=0; j<Finishs.size(); j++) {
|
||||
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
|
||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// bool ok=true;
|
||||
// for (int i=0; i<Starts.size(); i++)
|
||||
// for (int j=0; j<Finishs.size(); j++)
|
||||
// if (waveTrace(Starts.at(i),Finishs.at(j))<0) ok = false;
|
||||
// qDebug()<<"ok="<<ok;
|
||||
// if (!ok)
|
||||
// {
|
||||
// Cells[pos.x()][pos.y()]=AlienPath+playerId;
|
||||
// return false;
|
||||
// }
|
||||
//Cells[pos.x()][pos.y()]=PlayerTower-playerId;
|
||||
if (!isReachable(playerId,pos)) return false;
|
||||
bool * pathOK;
|
||||
pathOK = new bool();
|
||||
*pathOK = true;
|
||||
//qDebug("emit");
|
||||
pathOK = new bool(true);
|
||||
emit recreateAlienPath(pathOK);
|
||||
qDebug() << *pathOK;
|
||||
if (!pathOK)
|
||||
{
|
||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
||||
emit recreateAlienPath(pathOK);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
qDebug() << Cells[pos.x()][pos.y()] << Cells[pos.x()+1][pos.y()] << Cells[pos.x()][pos.y()+1] << Cells[pos.x()+1][pos.y()+1];
|
||||
qDebug() << playerId;
|
||||
if (*pathOK)
|
||||
return true;
|
||||
else
|
||||
delTowerOnMap(playerId,pos);
|
||||
}
|
||||
qDebug()<<"Dont buid here" << pos;
|
||||
return false;
|
||||
|
||||
3
map.h
3
map.h
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
explicit Map(QByteArray data, QSize size, QString name, int maxPlayers, int image, QObject *parent = 0);
|
||||
bool addTowerOnMap(int playerId, QPoint pos);
|
||||
bool isFreePlace(QPoint pos);
|
||||
//bool isFreePlace(QPoint pos);
|
||||
void delTowerOnMap(int playerId, QPoint pos);
|
||||
void removeAliensPath();
|
||||
QVector <QPointF> createPath(QPoint start, QPoint finish);
|
||||
@@ -62,6 +62,7 @@ private:
|
||||
|
||||
QVector<QPoint> invWaveTrace(QPoint finish, int cnt);
|
||||
int waveTrace(QPoint start, QPoint finish);
|
||||
bool isReachable(int playerId, QPoint pos);
|
||||
//void CreateMapExample();
|
||||
//void ReadSettings();
|
||||
};
|
||||
|
||||
@@ -22,11 +22,9 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
||||
qCritical("ERROR out of towers range");
|
||||
return false;
|
||||
}
|
||||
QRect alrec(pos,QSize(1,1));
|
||||
QRect alrec(pos,QSize(2,2));
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
if (alrec.contains((*i).pos.toPoint())) return false;
|
||||
}
|
||||
TowerType tw;
|
||||
tw.src = srcId;
|
||||
tw.imgType = gameData->players.at(playerId)->srcTowers.at(srcId).imgType;
|
||||
|
||||
Reference in New Issue
Block a user