2018-01-27 09:08:17 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2018 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
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
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "debris.h"
|
|
|
|
|
|
|
|
static void tick(void);
|
|
|
|
static void action(void);
|
|
|
|
static void touch(Entity *other);
|
|
|
|
|
2018-02-05 09:37:54 +01:00
|
|
|
void initDebris(Decoration *d)
|
2018-01-27 09:08:17 +01:00
|
|
|
{
|
2018-02-05 09:37:54 +01:00
|
|
|
initEntity((Entity*)d);
|
2018-01-27 09:08:17 +01:00
|
|
|
|
2018-01-28 10:34:14 +01:00
|
|
|
d->type = ET_DECORATION;
|
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
d->effectType = rand() % 2;
|
2018-01-27 09:08:17 +01:00
|
|
|
|
2018-02-05 23:06:53 +01:00
|
|
|
d->spriteFrame = 0;
|
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
d->flags |= EF_BOUNCES | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
2018-01-27 09:08:17 +01:00
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
d->tick = tick;
|
|
|
|
d->action = action;
|
|
|
|
d->touch = touch;
|
2018-01-27 09:08:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tick(void)
|
|
|
|
{
|
|
|
|
self->health--;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void action(void)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
Decoration *d;
|
|
|
|
|
|
|
|
d = (Decoration*)self;
|
|
|
|
|
|
|
|
if (d->effectType == 0)
|
2018-01-27 09:08:17 +01:00
|
|
|
{
|
2018-02-27 22:55:15 +01:00
|
|
|
addFlameParticles(d->x + (rand() % d->w), d->y + (rand() % d->h), d->isOnGround);
|
2018-01-27 09:08:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-27 22:55:15 +01:00
|
|
|
addSmokeParticles(d->x + (rand() % d->w), d->y + (rand() % d->h), d->isOnGround);
|
2018-01-27 09:08:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
self->thinkTime = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void touch(Entity *other)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
Decoration *d;
|
|
|
|
|
|
|
|
d = (Decoration*)self;
|
|
|
|
|
2018-01-27 09:08:17 +01:00
|
|
|
if (other == NULL)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
d->dx *= 0.9;
|
2018-01-27 09:08:17 +01:00
|
|
|
}
|
|
|
|
}
|