2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
2015-03-01 21:37:32 +01:00
|
|
|
Copyright (C) 2011, 2012 Guus Sliepen
|
|
|
|
Copyright (C) 2015 Julian Marchant
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
as published by the Free Software Foundation; either version 3
|
2011-08-24 14:14:44 +02:00
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-02-26 17:20:36 +01:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-24 14:14:44 +02:00
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
void addDebris(int x, int y, int amount)
|
|
|
|
{
|
|
|
|
if ((rand() % 2) == 0)
|
2015-03-08 15:38:58 +01:00
|
|
|
audio_playSound(SFX_DEBRIS, x);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2015-03-08 15:38:58 +01:00
|
|
|
audio_playSound(SFX_DEBRIS2, x);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
object *debris;
|
|
|
|
|
2011-08-26 23:27:16 +02:00
|
|
|
amount = rrand(3, rand() % amount);
|
|
|
|
limitInt(&amount, 3, 8);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
for (int i = 0 ; i < amount ; i++)
|
|
|
|
{
|
|
|
|
debris = new object;
|
|
|
|
|
|
|
|
debris->next = NULL;
|
|
|
|
debris->x = x;
|
|
|
|
debris->y = y;
|
|
|
|
|
2011-08-26 23:27:16 +02:00
|
|
|
debris->thinktime = rrand(60, 180);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:27:16 +02:00
|
|
|
debris->dx = rrand(-500, 500);
|
|
|
|
debris->dy = rrand(-500, 500);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (debris->dx != 0)
|
|
|
|
debris->dx /= 100;
|
|
|
|
|
|
|
|
if (debris->dy != 0)
|
|
|
|
debris->dy /= 100;
|
|
|
|
|
|
|
|
engine.debrisTail->next = debris;
|
|
|
|
engine.debrisTail = debris;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void doDebris()
|
|
|
|
{
|
|
|
|
object *prevDebris = engine.debrisHead;
|
|
|
|
object *debris = engine.debrisHead;
|
|
|
|
engine.debrisTail = engine.debrisHead;
|
|
|
|
|
|
|
|
while (debris->next != NULL)
|
|
|
|
{
|
|
|
|
debris = debris->next;
|
|
|
|
|
|
|
|
if (debris->thinktime > 0)
|
|
|
|
{
|
|
|
|
debris->thinktime--;
|
|
|
|
|
2015-02-27 05:23:08 +01:00
|
|
|
debris->x += engine.ssx + engine.smx;
|
|
|
|
debris->y += engine.ssy + engine.smy;
|
2011-08-24 14:14:44 +02:00
|
|
|
debris->x += debris->dx;
|
|
|
|
debris->y += debris->dy;
|
|
|
|
|
2011-08-26 23:27:16 +02:00
|
|
|
addExplosion(debris->x + rrand(-10, 10), debris->y + rrand(-10, 10), E_BIG_EXPLOSION);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (debris->thinktime < 1)
|
|
|
|
{
|
|
|
|
prevDebris->next = debris->next;
|
|
|
|
delete debris;
|
|
|
|
debris = prevDebris;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prevDebris = debris;
|
|
|
|
engine.debrisTail = debris;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|