rev |
line source |
nuclear@0
|
1 #include <stdio.h>
|
nuclear@0
|
2 #include <stdlib.h>
|
nuclear@0
|
3 #include "opengl.h"
|
nuclear@1
|
4 #include "effect.h"
|
nuclear@0
|
5 #include "psys.h"
|
nuclear@0
|
6
|
nuclear@0
|
7 #include "hello1.h"
|
nuclear@0
|
8 #include "hello2.h"
|
nuclear@0
|
9 #include "pimg.h"
|
nuclear@0
|
10
|
nuclear@0
|
11 static PSysParam ppmain;
|
nuclear@0
|
12 static PSysParam ppexpl, ppflame;
|
nuclear@0
|
13
|
nuclear@0
|
14 static ParticleSystem psys;
|
nuclear@0
|
15 static Image *pimg;
|
nuclear@0
|
16 static Image *simg[2];
|
nuclear@0
|
17
|
nuclear@1
|
18 bool fx_init()
|
nuclear@0
|
19 {
|
nuclear@0
|
20 ppmain.spawn_rate = 20000;
|
nuclear@0
|
21 ppmain.size = 0.06;
|
nuclear@0
|
22 ppmain.spawn_range = 0.01;
|
nuclear@0
|
23 ppmain.life = 0.4;
|
nuclear@0
|
24 ppmain.gravity = Vector3(0, 0.01, 0);
|
nuclear@0
|
25
|
nuclear@0
|
26 ppmain.pcolor_start = Vector3(0.717, 0.494, 0.951) * 0.6;
|
nuclear@0
|
27 ppmain.pcolor_end = Vector3(0.9, 0.135, 0.005) * 0.6;
|
nuclear@0
|
28 ppmain.pcolor_mid = lerp(ppmain.pcolor_start, ppmain.pcolor_mid, 0.5);
|
nuclear@0
|
29
|
nuclear@0
|
30 ppmain.palpha_start = 1.0;
|
nuclear@0
|
31 ppmain.palpha_mid = 0.5;
|
nuclear@0
|
32 ppmain.palpha_end = 0.0;
|
nuclear@0
|
33
|
nuclear@0
|
34 ppmain.pscale_start = 1.0;
|
nuclear@0
|
35 ppmain.pscale_mid = 1.0;
|
nuclear@0
|
36 ppmain.pscale_end = 7.0;
|
nuclear@0
|
37
|
nuclear@0
|
38 pimg = new Image;
|
nuclear@0
|
39 pimg->pixels = (unsigned char*)img_particle.pixel_data;
|
nuclear@0
|
40 pimg->width = img_particle.width;
|
nuclear@0
|
41 pimg->height = img_particle.height;
|
nuclear@0
|
42
|
nuclear@0
|
43 ppmain.pimg = pimg;
|
nuclear@0
|
44
|
nuclear@0
|
45 simg[0] = new Image;
|
nuclear@0
|
46 simg[0]->pixels = (unsigned char*)img_hello1.pixel_data;
|
nuclear@0
|
47 simg[0]->width = img_hello1.width;
|
nuclear@0
|
48 simg[0]->height = img_hello1.height;
|
nuclear@0
|
49
|
nuclear@0
|
50 simg[1] = new Image;
|
nuclear@0
|
51 simg[1]->pixels = (unsigned char*)img_hello2.pixel_data;
|
nuclear@0
|
52 simg[1]->width = img_hello2.width;
|
nuclear@0
|
53 simg[1]->height = img_hello2.height;
|
nuclear@0
|
54
|
nuclear@0
|
55 ppmain.spawn_map = simg[0];
|
nuclear@0
|
56 ppmain.spawn_map_speed = 0.8;
|
nuclear@0
|
57 psys.pp = ppmain;
|
nuclear@0
|
58
|
nuclear@0
|
59 // explosion parameters
|
nuclear@0
|
60 ppexpl = ppmain;
|
nuclear@0
|
61 ppexpl.pcolor_start = ppmain.pcolor_mid;
|
nuclear@0
|
62 ppexpl.pcolor_mid = lerp(ppexpl.pcolor_start, ppexpl.pcolor_end, 0.5);
|
nuclear@0
|
63
|
nuclear@0
|
64 ppexpl.palpha_start = 1.0;
|
nuclear@0
|
65 ppexpl.palpha_mid = 0.5;
|
nuclear@0
|
66 ppexpl.palpha_end = 0.05;
|
nuclear@0
|
67
|
nuclear@0
|
68 ppexpl.pscale_start = 1.0;
|
nuclear@0
|
69 ppexpl.pscale_mid = 3.0;
|
nuclear@0
|
70 ppexpl.pscale_end = 5.0;
|
nuclear@0
|
71 ppexpl.gravity = Vector3(0, -6, 0);
|
nuclear@0
|
72
|
nuclear@0
|
73 // flame parameters
|
nuclear@0
|
74 ppflame = ppexpl;
|
nuclear@0
|
75 ppflame.pcolor_start = Vector3(1.0, 0.8, 0.2) * 0.5;
|
nuclear@0
|
76 ppflame.pcolor_mid = Vector3(1.0, 0.3, 0.2) * 0.5;
|
nuclear@0
|
77 ppflame.pcolor_end = Vector3(0.1, 0.1, 0.1);
|
nuclear@0
|
78 //ppflame.pcolor_mid = lerp(ppflame.pcolor_start, ppflame.pcolor_end, 0.6);
|
nuclear@0
|
79
|
nuclear@0
|
80 ppflame.life = 0.5;
|
nuclear@0
|
81 ppflame.life_range = 0.25;
|
nuclear@0
|
82 ppflame.size = 0.07;
|
nuclear@0
|
83 ppflame.size_range = 0.03;
|
nuclear@0
|
84 ppflame.spawn_rate = 18000;
|
nuclear@0
|
85 ppflame.gravity = Vector3(0, 2, 0);
|
nuclear@0
|
86
|
nuclear@0
|
87 ppflame.palpha_start *= 0.7;
|
nuclear@0
|
88 ppflame.palpha_mid *= 0.7;
|
nuclear@0
|
89 ppflame.palpha_end *= 0.7;
|
nuclear@0
|
90
|
nuclear@0
|
91 return true;
|
nuclear@0
|
92 }
|
nuclear@0
|
93
|
nuclear@1
|
94 void fx_cleanup()
|
nuclear@0
|
95 {
|
nuclear@0
|
96 delete pimg;
|
nuclear@0
|
97 delete simg[0];
|
nuclear@0
|
98 delete simg[1];
|
nuclear@0
|
99 }
|
nuclear@0
|
100
|
nuclear@1
|
101 void fx_draw(unsigned long msec)
|
nuclear@0
|
102 {
|
nuclear@0
|
103 static unsigned long prev_msec;
|
nuclear@0
|
104 float dt = (msec - prev_msec) / 1000.0;
|
nuclear@0
|
105 prev_msec = msec;
|
nuclear@0
|
106
|
nuclear@0
|
107 psys.update(dt);
|
nuclear@0
|
108 psys.draw();
|
nuclear@0
|
109 }
|
nuclear@0
|
110
|
nuclear@1
|
111 void fx_dbg()
|
nuclear@0
|
112 {
|
nuclear@0
|
113 psys.explode(Vector3(0, 0, 0), 2.5, ppflame.life, 1.5);
|
nuclear@0
|
114 psys.pp = ppflame;
|
nuclear@0
|
115 //psys.explode(Vector3(0, -0.2, 0), 3.0, 1.5);
|
nuclear@0
|
116 //psys.pp = ppexpl;
|
nuclear@0
|
117 }
|