some bugfix in splashes
This commit is contained in:
@@ -20,7 +20,7 @@ AD_Core::AD_Core(QObject *parent) :
|
|||||||
adtowers = new Towers(addata);
|
adtowers = new Towers(addata);
|
||||||
adsplashes = new Splashes(addata);
|
adsplashes = new Splashes(addata);
|
||||||
connect(addata->map,SIGNAL(recreateAlienPath(bool*)),adaliens,SLOT(retrace(bool*)));
|
connect(addata->map,SIGNAL(recreateAlienPath(bool*)),adaliens,SLOT(retrace(bool*)));
|
||||||
connect(adtowers,SIGNAL(shot(srcSplashType,int,TowerType)),adsplashes,SLOT(addSplash(srcSplashType,int,TowerType)));
|
connect(adtowers,SIGNAL(shot(QPoint)),adsplashes,SLOT(addSplash(QPoint)));
|
||||||
// adaliens->addAlien(0);
|
// adaliens->addAlien(0);
|
||||||
// adaliens->AddAlien(0);
|
// adaliens->AddAlien(0);
|
||||||
// adaliens->AddAlien(0);
|
// adaliens->AddAlien(0);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<value key="QtVersionId" type="int">0</value>
|
<value key="QtVersionId" type="int">0</value>
|
||||||
<value key="ToolChain" type="int">0</value>
|
<value key="ToolChain" type="int">0</value>
|
||||||
|
<value key="addQDumper" type=""></value>
|
||||||
<value key="buildConfiguration" type="int">2</value>
|
<value key="buildConfiguration" type="int">2</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
||||||
<value key="QtVersionId" type="int">0</value>
|
<value key="QtVersionId" type="int">0</value>
|
||||||
|
<value key="addQDumper" type=""></value>
|
||||||
<value key="buildConfiguration" type="int">0</value>
|
<value key="buildConfiguration" type="int">0</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
@@ -166,6 +168,46 @@
|
|||||||
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</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-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">true</value>
|
||||||
|
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||||
|
<value type="QString">clean</value>
|
||||||
|
<value type="QString">-w</value>
|
||||||
|
</valuelist>
|
||||||
|
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
|
||||||
|
<value key="abstractProcess.enabled" type="bool">true</value>
|
||||||
|
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender</value>
|
||||||
<value key="cleanConfig" type="bool">true</value>
|
<value key="cleanConfig" type="bool">true</value>
|
||||||
<valuelist key="makeargs" type="QVariantList">
|
<valuelist key="makeargs" type="QVariantList">
|
||||||
<value type="QString">clean</value>
|
<value type="QString">clean</value>
|
||||||
|
|||||||
22
base_types.h
22
base_types.h
@@ -62,6 +62,7 @@ struct srcTriggerType
|
|||||||
nearlestAlien
|
nearlestAlien
|
||||||
};
|
};
|
||||||
int childId; // =-1 for none birth splash (e.q. only damage)
|
int childId; // =-1 for none birth splash (e.q. only damage)
|
||||||
|
aimType childAim;
|
||||||
bool delParent;
|
bool delParent;
|
||||||
float damage;
|
float damage;
|
||||||
float radius;
|
float radius;
|
||||||
@@ -72,13 +73,26 @@ struct srcTriggerType
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TriggerType
|
struct TriggerOnDest
|
||||||
|
{
|
||||||
|
int src;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TriggerOnTimer
|
||||||
{
|
{
|
||||||
int src;
|
int src;
|
||||||
unsigned int timer;
|
unsigned int timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TriggerOnAlien
|
||||||
|
{
|
||||||
|
int src;
|
||||||
|
QList <int> triggerAliens;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct srcSplashType
|
struct srcSplashType
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
@@ -96,12 +110,16 @@ struct SplashType
|
|||||||
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
|
||||||
|
int srcTower;
|
||||||
|
int PlayerId;
|
||||||
int AlienId; // aim alien (different from tower.AlienId)
|
int AlienId; // aim alien (different from tower.AlienId)
|
||||||
QPointF destination;
|
QPointF destination;
|
||||||
int life; // in ticks
|
int life; // in ticks
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
QList <TriggerType> triggers;
|
QList <TriggerOnAlien> trigsOnAlien;
|
||||||
|
QList <TriggerOnDest> trigsOnDest;
|
||||||
|
QList <TriggerOnTimer> trigsOnTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -372,6 +372,8 @@ void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, sr
|
|||||||
strigt.randomPosRadius = tbtrig.randomPosRadius;
|
strigt.randomPosRadius = tbtrig.randomPosRadius;
|
||||||
strigt.timer = tbtrig.timer;
|
strigt.timer = tbtrig.timer;
|
||||||
strigt.type = tbtrig.type;
|
strigt.type = tbtrig.type;
|
||||||
|
strigt.childAim = tbtrig.childAim;
|
||||||
|
strigt.childId = -1;
|
||||||
stt->triggers.append(strigt);
|
stt->triggers.append(strigt);
|
||||||
trigIds->append(trigid);
|
trigIds->append(trigid);
|
||||||
}
|
}
|
||||||
|
|||||||
131
splashes.cpp
131
splashes.cpp
@@ -11,8 +11,11 @@ Splashes::Splashes(Game_Data *gd, QObject *parent) :
|
|||||||
|
|
||||||
bool Splashes::addSplash(int srcId, QPointF pos)
|
bool Splashes::addSplash(int srcId, QPointF pos)
|
||||||
{
|
{
|
||||||
qFatal("don't use this function addSplash(int srcId, QPointF pos)");
|
qDebug("don't use this function addSplash(int srcId, QPointF pos)");
|
||||||
if (srcId < 0 || srcId >= gameData->srcSplashes.size())
|
return false;
|
||||||
|
// FIXME: говнокод
|
||||||
|
// TODO: find and correct errors here
|
||||||
|
/* if (srcId < 0 || srcId >= gameData->srcSplashes.size())
|
||||||
{
|
{
|
||||||
qCritical("ERROR out of splashes range");
|
qCritical("ERROR out of splashes range");
|
||||||
return false;
|
return false;
|
||||||
@@ -42,36 +45,61 @@ bool Splashes::addSplash(int srcId, QPointF pos)
|
|||||||
}
|
}
|
||||||
gameData->curSplashes.insert(spl.id,spl);
|
gameData->curSplashes.insert(spl.id,spl);
|
||||||
nextId++;
|
nextId++;
|
||||||
return true;
|
return true;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::addSplash(srcSplashType src, int index, TowerType tw)
|
void Splashes::addSplash(QPoint curTowerId)
|
||||||
{
|
{
|
||||||
SplashType spl;
|
if (gameData->curTowers.contains(curTowerId))
|
||||||
spl.id = nextId;
|
|
||||||
spl.TowerId = tw.pos;
|
|
||||||
if (!gameData->curAliens.contains(tw.aim))
|
|
||||||
qFatal("Error finding splash aim! Tower has nvalid aim!");
|
|
||||||
spl.destination = gameData->curAliens.value(tw.aim).pos;
|
|
||||||
if (src.autoControl)
|
|
||||||
spl.AlienId = tw.aim;
|
|
||||||
else
|
|
||||||
spl.AlienId = -1;
|
|
||||||
spl.angle = tw.angle; // FIXME: tower not rotate
|
|
||||||
spl.pos = tw.pos; // FIXME: pos not in center or left-angle of tower
|
|
||||||
spl.imgType = src.imgType;
|
|
||||||
spl.life = 0;
|
|
||||||
spl.src = index;
|
|
||||||
TriggerType trig;
|
|
||||||
for(int i=0; i<src.triggerIndexes.size(); i++)
|
|
||||||
{
|
{
|
||||||
trig.timer = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).triggers.at(src.triggerIndexes.at(i)).timer;
|
TowerType tw = gameData->curTowers.value(curTowerId);
|
||||||
trig.src = src.triggerIndexes.at(i);
|
srcSplashType src = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).splashes.at(0);
|
||||||
spl.triggers.push_back(trig);
|
SplashType spl;
|
||||||
|
spl.id = nextId;
|
||||||
|
spl.TowerId = curTowerId;
|
||||||
|
spl.srcTower = tw.src;
|
||||||
|
spl.PlayerId = tw.PlayerId;
|
||||||
|
if (!gameData->curAliens.contains(tw.aim))
|
||||||
|
qFatal("Error finding splash aim! Tower has nvalid aim!");
|
||||||
|
spl.destination = gameData->curAliens.value(tw.aim).pos;
|
||||||
|
if (src.autoControl)
|
||||||
|
spl.AlienId = tw.aim;
|
||||||
|
else
|
||||||
|
spl.AlienId = -1;
|
||||||
|
spl.angle = tw.angle;
|
||||||
|
spl.pos = tw.pos; // FIXME: splash do not create in center or left-angle of tower, it must be in tower's side
|
||||||
|
spl.imgType = src.imgType;
|
||||||
|
spl.life = 0;
|
||||||
|
spl.src = 0;
|
||||||
|
//TriggerType trig;
|
||||||
|
for(int i=0; i<src.triggerIndexes.size(); i++)
|
||||||
|
{
|
||||||
|
srcTriggerType trig;
|
||||||
|
TriggerOnDest tod;
|
||||||
|
TriggerOnAlien toa;
|
||||||
|
TriggerOnTimer tot;
|
||||||
|
trig = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).triggers.at(src.triggerIndexes.at(i));
|
||||||
|
switch (trig.type)
|
||||||
|
{
|
||||||
|
case srcTriggerType::onDestination :
|
||||||
|
tod.src = src.triggerIndexes.at(i);
|
||||||
|
spl.trigsOnDest.append(tod);
|
||||||
|
break;
|
||||||
|
case srcTriggerType::onAlienInRadius :
|
||||||
|
toa.src = src.triggerIndexes.at(i);
|
||||||
|
spl.trigsOnAlien.append(toa);
|
||||||
|
break;
|
||||||
|
case srcTriggerType::onTimer :
|
||||||
|
tot.src = src.triggerIndexes.at(i);
|
||||||
|
tot.timer = trig.timer;
|
||||||
|
spl.trigsOnTimer.append(tot);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gameData->curSplashes.insert(spl.id,spl);
|
||||||
|
nextId++;
|
||||||
}
|
}
|
||||||
gameData->curSplashes.insert(spl.id,spl);
|
|
||||||
nextId++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,30 +122,39 @@ void Splashes::update()
|
|||||||
//isTowerSplash = true;
|
//isTowerSplash = true;
|
||||||
//if (!isTowerSplash)
|
//if (!isTowerSplash)
|
||||||
// src = gameData->srcSplashes.at(spl.src);
|
// src = gameData->srcSplashes.at(spl.src);
|
||||||
if (src.autoControl)
|
if (src.autoControl)
|
||||||
|
{
|
||||||
|
bool badAl = false;
|
||||||
|
if (gameData->curAliens.contains(spl.AlienId))
|
||||||
|
spl.destination = gameData->curAliens.value(spl.AlienId).pos;
|
||||||
|
else
|
||||||
|
badAl = true;
|
||||||
|
if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
|
||||||
{
|
{
|
||||||
if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
|
if (badAl)
|
||||||
deadIndexes.push_back(spl.id);
|
deadIndexes.push_back(spl.id);
|
||||||
if (gameData->curAliens.contains(spl.AlienId))
|
spl.pos = spl.destination;
|
||||||
spl.destination = gameData->curAliens.value(spl.AlienId).pos;
|
for (int k=0; k<spl.trigsOnDest.size(); k++)
|
||||||
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
|
{
|
||||||
//if (tmpdy < 0) arctg=arctg+M_PI;
|
// TODO: activate trigger
|
||||||
angl = 180.0f*(-arctg)/M_PI;
|
}
|
||||||
|
|
||||||
spl.angle = angl;
|
|
||||||
|
|
||||||
spl.pos.setX(spl.pos.x()
|
|
||||||
-src.speed*std::sin(arctg));
|
|
||||||
spl.pos.setY(spl.pos.y()
|
|
||||||
-src.speed*std::cos(arctg));
|
|
||||||
} else {
|
|
||||||
if (!gameData->map->rect().contains(spl.pos.toPoint()))
|
|
||||||
deadIndexes.push_back(spl.id);
|
|
||||||
spl.pos.setX(spl.pos.x()
|
|
||||||
-src.speed*std::sin(-spl.angle*M_PI/180.f));
|
|
||||||
spl.pos.setY(spl.pos.y()
|
|
||||||
-src.speed*std::cos(-spl.angle*M_PI/180.f));
|
|
||||||
}
|
}
|
||||||
|
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
|
||||||
|
//if (tmpdy < 0) arctg=arctg+M_PI;
|
||||||
|
angl = 180.0f*(-arctg)/M_PI;
|
||||||
|
spl.angle = angl;
|
||||||
|
spl.pos.setX(spl.pos.x()
|
||||||
|
-src.speed*std::sin(arctg));
|
||||||
|
spl.pos.setY(spl.pos.y()
|
||||||
|
-src.speed*std::cos(arctg));
|
||||||
|
} else {
|
||||||
|
if (!gameData->map->rect().contains(spl.pos.toPoint()))
|
||||||
|
deadIndexes.push_back(spl.id);
|
||||||
|
spl.pos.setX(spl.pos.x()
|
||||||
|
-src.speed*std::sin(-spl.angle*M_PI/180.f));
|
||||||
|
spl.pos.setY(spl.pos.y()
|
||||||
|
-src.speed*std::cos(-spl.angle*M_PI/180.f));
|
||||||
|
}
|
||||||
// TODO: smooth splash rotate
|
// TODO: smooth splash rotate
|
||||||
// TODO: activate trigger and more...
|
// TODO: activate trigger and more...
|
||||||
gameData->curSplashes.insert(spl.id,spl);
|
gameData->curSplashes.insert(spl.id,spl);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addSplash(srcSplashType src, int index, TowerType tw);
|
void addSplash(QPoint towerId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Game_Data *gameData;
|
Game_Data *gameData;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void Towers::update()
|
|||||||
if ((*i).aim > 0)
|
if ((*i).aim > 0)
|
||||||
{
|
{
|
||||||
(*i).reload = 0;
|
(*i).reload = 0;
|
||||||
emit shot(stw.splashes.at(0), 0, (*i));
|
emit shot((*i).pos);
|
||||||
//qDebug("shot!");
|
//qDebug("shot!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user