2 Copyright © 2004 Parallel Realities
3 Copyright © 2007-2008 Kővágó Zoltán <DirtY.iCE.hu@gmail.com>
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.
25 #include "CGraphics.h"
29 void addEffect(float x
, float y
, float dx
, float dy
, int flags
)
31 Effect
*effect
= new Effect();
33 effect
->create(x
, y
, dx
, dy
, flags
);
35 map
.addEffect(effect
);
38 void addColoredEffect(float x
, float y
, float dx
, float dy
, int color
, int flags
)
40 Effect
*effect
= new Effect();
42 effect
->create(x
, y
, dx
, dy
, flags
);
43 effect
->health
= Math::rrand(60, 90);
44 effect
->color
= color
;
46 map
.addEffect(effect
);
49 void addSmokeAndFire(Entity
*ent
, float dx
, float dy
, int amount
)
53 for (int i
= 0 ; i
< amount
; i
++)
55 x
= (int)(ent
->x
+ rand() % ent
->width
);
56 y
= (int)(ent
->y
+ rand() % ent
->height
);
59 addEffect(x
, y
, dx
, dy
, EFF_TRAILSFIRE
);
63 addEffect(x
, y
, dx
, dy
, EFF_SMOKES
);
68 void addBlood(Entity
*ent
, float dx
, float dy
, int amount
)
72 if (engine
.cheatBlood
)
79 for (int i
= 0 ; i
< amount
; i
++)
81 x
= (int)(ent
->x
+ rand() % ent
->width
);
82 y
= (int)(ent
->y
+ rand() % ent
->height
);
83 addEffect(x
, y
, dx
, dy
, EFF_BLEEDS
);
90 Effect
*effect
= (Effect
*)map
.effectList
.getHead();
91 Effect
*previous
= effect
;
93 Sprite
*blood
= graphics
.getSprite("RedBloodParticle", true);
94 Sprite
*explosion
= graphics
.getSprite("SmallExplosion", true);
95 Sprite
*smoke
= graphics
.getSprite("Smoke", true);
99 while (effect
->next
!= NULL
)
101 effect
= (Effect
*)effect
->next
;
105 if (effect
->flags
& EFF_BLEEDS
)
107 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, blood
, PAR_COLLIDES
);
109 else if (effect
->flags
& EFF_TRAILSFIRE
)
111 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, explosion
, PAR_COLLIDES
);
113 else if (effect
->flags
& EFF_SMOKES
)
115 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), graphics
.red
, smoke
, PAR_COLLIDES
);
117 else if (effect
->flags
& EFF_COLORED
)
119 map
.addParticle(effect
->x
, effect
->y
, 0, 1, Math::rrand(5, 30), effect
->color
, NULL
, PAR_COLLIDES
);
122 x
= (int)(effect
->x
- map
.offsetX
);
123 y
= (int)(effect
->y
- map
.offsetY
);
125 if ((x
< 0) || (y
< 0))
131 x
= (int)effect
->x
>> BRICKSHIFT
;
132 y
= (int)effect
->y
>> BRICKSHIFT
;
134 if (map
.isSolid(x
, y
))
140 if (effect
->health
> 0)
146 map
.effectList
.remove(previous
, effect
);