2 Copyright (C) 2004 Parallel Realities
3 Copyright (C) 2007 Kővágó Zoltán
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 void addEffect(float x
, float y
, float dx
, float dy
, int flags
)
26 Effect
*effect
= new Effect();
28 effect
->create(x
, y
, dx
, dy
, flags
);
30 map
.addEffect(effect
);
33 void addColoredEffect(float x
, float y
, float dx
, float dy
, int color
, int flags
)
35 Effect
*effect
= new Effect();
37 effect
->create(x
, y
, dx
, dy
, flags
);
38 effect
->health
= Math::rrand(60, 90);
39 effect
->color
= color
;
41 map
.addEffect(effect
);
44 void addSmokeAndFire(Entity
*ent
, float dx
, float dy
, int amount
)
48 for (int i
= 0 ; i
< amount
; i
++)
50 x
= (int)(ent
->x
+ rand() % ent
->width
);
51 y
= (int)(ent
->y
+ rand() % ent
->height
);
54 addEffect(x
, y
, dx
, dy
, EFF_TRAILSFIRE
);
58 addEffect(x
, y
, dx
, dy
, EFF_SMOKES
);
63 void addBlood(Entity
*ent
, float dx
, float dy
, int amount
)
67 if (engine
.cheatBlood
)
74 for (int i
= 0 ; i
< amount
; i
++)
76 x
= (int)(ent
->x
+ rand() % ent
->width
);
77 y
= (int)(ent
->y
+ rand() % ent
->height
);
78 addEffect(x
, y
, dx
, dy
, EFF_BLEEDS
);
85 Effect
*effect
= (Effect
*)map
.effectList
.getHead();
86 Effect
*previous
= effect
;
88 Sprite
*blood
= graphics
.getSprite("RedBloodParticle", true);
89 Sprite
*explosion
= graphics
.getSprite("SmallExplosion", true);
90 Sprite
*smoke
= graphics
.getSprite("Smoke", true);
94 while (effect
->next
!= NULL
)
96 effect
= (Effect
*)effect
->next
;
100 if (effect
->flags
& EFF_BLEEDS
)
102 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, blood
, PAR_COLLIDES
);
104 else if (effect
->flags
& EFF_TRAILSFIRE
)
106 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, explosion
, PAR_COLLIDES
);
108 else if (effect
->flags
& EFF_SMOKES
)
110 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, smoke
, PAR_COLLIDES
);
112 else if (effect
->flags
& EFF_COLORED
)
114 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), effect
->color
, NULL
, PAR_COLLIDES
);
117 x
= (int)(effect
->x
- map
.offsetX
);
118 y
= (int)(effect
->y
- map
.offsetY
);
120 if ((x
< 0) || (y
< 0))
126 x
= (int)effect
->x
>> BRICKSHIFT
;
127 y
= (int)effect
->y
>> BRICKSHIFT
;
129 if (map
.isSolid(x
, y
))
135 if (effect
->health
> 0)
141 map
.effectList
.remove(previous
, effect
);