1 // -----------------------------------------------
3 // -----------------------------------------------
4 // Many particle types, designed to be used with
5 // my particle manager.
6 // -----------------------------------------------
7 // Developed By Kronoman - Copyright (c) 2004
8 // In loving memory of my father
9 // -----------------------------------------------
14 // -----------------------------------------------
15 // Spark particle render
16 // -----------------------------------------------
17 void CSparkParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
19 line(bmp
, (int)x
- xd
, (int)y
- yd
, (int)(x
+ dx
*scale_spark
- xd
), (int)(y
+ dy
*scale_spark
- yd
), color
);
22 // -----------------------------------------------
23 // Circle particle render
24 // -----------------------------------------------
25 void CCircleParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
27 circlefill(bmp
, (int)x
- xd
, (int)y
- yd
, radius
, color
);
30 // -----------------------------------------------
31 // Rect particle render
32 // -----------------------------------------------
33 void CRectParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
35 rectfill(bmp
, (int)x
- xd
, (int)y
- yd
, (int)(x
+ size
- xd
), (int)(y
+ size
- yd
), color
);
38 // -----------------------------------------------
39 // Text particle render
40 // -----------------------------------------------
41 void CTextParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
43 text_mode(-1); // DEBUG -- TEXT ALWAYS TRANSPARENT :O
44 textout_centre(bmp
, font_text
, text_to_show
.c_str(), (int)x
- xd
, (int)y
- yd
, color
);
47 // -----------------------------------------------
48 // Explosive text particle
49 // -----------------------------------------------
50 bool CExplosiveTextParticle::update_logic(CParticleManager
&particle_manager
)
52 // when life == 1, spawn particles
57 while ( (yt
+=rand()%3+1) < text_height(font_text
) )
59 while ( (xt
+=rand()%3+1) < text_length(font_text
, text_to_show
.c_str() ) )
61 particle_manager
.add_particle(new CCircleParticle((int)x
+xt
, (int)y
+yt
, (float)((rand()%800)-400)/100.0,(float)((rand()%800)-400)/100.0 , color
, rand()%5+10, rand()%2+1));
66 return CTextParticle::update_logic(particle_manager
);
69 // -----------------------------------------------
70 // Bitmap particle render
71 // -----------------------------------------------
72 void CBitmapParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
74 if (spr
== NULL
) return;
75 draw_sprite(bmp
, spr
, (int)x
- xd
- spr
->w
/2, (int)y
- yd
- spr
->h
/2);
78 // -----------------------------------------------
79 // Rotating bitmap particle render & logic
80 // -----------------------------------------------
81 bool CRotoBitmapParticle::update_logic(CParticleManager
&particle_manager
)
84 if (angle
< 0.0) angle
= 255.0;
85 if (angle
> 255.0) angle
= 0.0;
87 return CBaseParticle::update_logic(particle_manager
);
90 void CRotoBitmapParticle::render_particle(BITMAP
*bmp
, int xd
, int yd
)
92 if (spr
== NULL
) return;
93 pivot_sprite(bmp
, spr
, (int)x
- xd
, (int)y
- yd
, spr
->w
/2, spr
->h
/2, ftofix(angle
));