2 Copyright (C) 2004-2010 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 void addEffect(float x, float y, float dx, float dy, int flags)
25 Effect *effect = new Effect();
27 effect->create(x, y, dx, dy, flags);
29 map.addEffect(effect);
32 void addColoredEffect(float x, float y, float dx, float dy, int color, int flags)
34 Effect *effect = new Effect();
36 effect->create(x, y, dx, dy, flags);
37 effect->health = Math::rrand(60, 90);
38 effect->color = color;
40 map.addEffect(effect);
43 void addSmokeAndFire(Entity *ent, float dx, float dy, int amount)
47 for (int i = 0 ; i < amount ; i++)
49 x = (int)(ent->x + Math::prand() % ent->width);
50 y = (int)(ent->y + Math::prand() % ent->height);
51 if ((Math::prand() % 4) > 0)
53 addEffect(x, y, dx, dy, EFF_TRAILSFIRE);
57 addEffect(x, y, dx, dy, EFF_SMOKES);
62 void addBlood(Entity *ent, float dx, float dy, int amount)
66 if (engine.cheatBlood)
73 for (int i = 0 ; i < amount ; i++)
75 x = (int)(ent->x + Math::prand() % ent->width);
76 y = (int)(ent->y + Math::prand() % ent->height);
77 addEffect(x, y, dx, dy, EFF_BLEEDS);
84 Effect *effect = (Effect*)map.effectList.getHead();
85 Effect *previous = effect;
87 Sprite *blood = graphics.getSprite("RedBloodParticle", true);
88 Sprite *explosion = graphics.getSprite("SmallExplosion", true);
89 Sprite *smoke = graphics.getSprite("Smoke", true);
93 while (effect->next != NULL)
95 effect = (Effect*)effect->next;
99 if (effect->flags & EFF_BLEEDS)
101 map.addParticle(effect->x, effect->y, 0, 1, Math::rrand(5, 30), graphics.red, blood, PAR_COLLIDES);
103 else if (effect->flags & EFF_TRAILSFIRE)
105 map.addParticle(effect->x, effect->y, 0, 1, Math::rrand(5, 30), graphics.red, explosion, PAR_COLLIDES);
107 else if (effect->flags & EFF_SMOKES)
109 map.addParticle(effect->x, effect->y, 0, 1, Math::rrand(5, 30), graphics.red, smoke, PAR_COLLIDES);
111 else if (effect->flags & EFF_COLORED)
113 map.addParticle(effect->x, effect->y, 0, 1, Math::rrand(5, 30), effect->color, NULL, PAR_COLLIDES);
116 x = (int)(effect->x - engine.playerPosX);
117 y = (int)(effect->y - engine.playerPosY);
119 if ((x < 0) || (y < 0))
125 x = (int)effect->x >> BRICKSHIFT;
126 y = (int)effect->y >> BRICKSHIFT;
128 if (map.isSolid(x, y))
134 if (effect->health > 0)
140 map.effectList.remove(previous, effect);