2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
48 static smoke_t sm
[MAXSMOK
];
49 static int sr_r
,sxr
[MAXSR
],syr
[MAXSR
];
52 static void *spr
[SMSN
],*fspr
[FLSN
];
57 0xBC,0xBA,0xB8,0xB6,0xB4,0xB2,0xB0,0xD5,0xD6,0xD7,0xA1,0xA0,0xE3,0xE2,0xE1,0xE0
60 void SMK_savegame(FILE* h
) {
63 for(i
=n
=0;i
<MAXSMOK
;++i
) if(sm
[i
].t
) ++n
;
65 for(i
=0;i
<MAXSMOK
;++i
) if(sm
[i
].t
) myfwrite(&sm
[i
],1,sizeof(sm
[0]),h
);
68 void SMK_loadgame(FILE* h
) {
72 myfread(sm
,1,n
*sizeof(sm
[0]),h
);
78 for(i
=0;i
<MAXSMOK
;++i
) {sm
[i
].t
=0;}
83 void SMK_alloc(void) {
86 burnsnd
=Z_getsnd("BURN");
87 for(i
=0;i
<SMSN
;++i
) spr
[i
]=Z_getspr("SMOK",i
,0,NULL
);
88 for(i
=0;i
<FLSN
;++i
) fspr
[i
]=Z_getspr("FLAM",i
,0,NULL
);
89 for(i
=0;i
<MAXSR
;++i
) {
90 sxr
[i
]=myrand(256*2+1)-256;
91 syr
[i
]=myrand(256*2+1)-256;
96 static void inclast(void) {
97 if(++lsm
>=MAXSMOK
) lsm
=0;
105 for(i
=0;i
<MAXSMOK
;++i
) if(sm
[i
].t
) {
107 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
108 sm
[i
].xv
=Z_dec(sm
[i
].xv
,20);
109 sm
[i
].yv
=Z_dec(sm
[i
].yv
,20);
110 sm
[i
].x
+=sm
[i
].xv
/2;sm
[i
].y
+=sm
[i
].yv
/2;
111 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
112 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
113 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
114 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
116 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
117 sm
[i
].x
+=sm
[i
].xv
/2;sm
[i
].y
+=sm
[i
].yv
/2;
118 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
119 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
120 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
121 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
124 o
.x
=sm
[i
].x
>>8;o
.y
=sm
[i
].y
>>8;
125 o
.xv
=sm
[i
].xv
>>10;o
.yv
=sm
[i
].yv
>>10;
127 if(!(g_time
&3)) Z_hit(&o
,1,sm
[i
].o
,HIT_FLAME
);
130 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
131 sm
[i
].xv
=Z_dec(sm
[i
].xv
,20);
132 sm
[i
].yv
=Z_dec(sm
[i
].yv
,20);
133 sm
[i
].x
+=sm
[i
].xv
;sm
[i
].y
+=sm
[i
].yv
;
134 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
135 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
136 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
137 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
144 void SMK_draw(void) {
147 for(i
=0;i
<MAXSMOK
;++i
) if(sm
[i
].t
) switch(sm
[i
].s
) {
149 if((s
=sm
[i
].t
)>=(SMSN
-1)*3) s
=0; else s
=SMSN
-1-s
/3;
150 V_sprf((sm
[i
].x
>>8)-w_x
+WD
/2,(sm
[i
].y
>>8)-w_y
+HT
/2+1+w_o
,spr
[s
],&smoke_sprf
);//V_sprf((sm[i].x>>8)-w_x+100,(sm[i].y>>8)-w_y+50+w_o,spr[s],&smoke_sprf);
153 if((s
=sm
[i
].t
)>=(FLSN
-1)) s
=0; else s
=FLSN
-1-s
;
154 V_sprf((sm
[i
].x
>>8)-w_x
+WD
/2,(sm
[i
].y
>>8)-w_y
+HT
/2+1+w_o
,fspr
[s
],&flame_sprf
);//V_sprf((sm[i].x>>8)-w_x+100,(sm[i].y>>8)-w_y+50+w_o,fspr[s],&flame_sprf);
159 void SMK_add(int x
,int y
,int xv
,int yv
,byte t
,byte s
,short o
) {
162 if(!Z_canfit(x
>>8,(y
>>8)+3,3,7)) return;
163 if(Z_inwater(x
>>8,(y
>>8)+3,3,7)) {FX_bubble(x
>>8,y
>>8,xv
,yv
,1);return;}
166 sm
[i
].xv
=xv
;sm
[i
].yv
=yv
;
172 void SMK_gas(int x0
,int y0
,int xr
,int yr
,int xv
,int yv
,int k
) {
178 k
=max(abs(xv
),abs(yv
));
181 x
=((xv
*i
/k
+x0
)<<8)+sxr
[sr_r
]*xr
;
182 y
=((yv
*i
/k
+y0
)<<8)+syr
[sr_r
]*yr
;
183 if(++sr_r
>=MAXSR
) sr_r
=0;
184 SMK_add(x
,y
,sxv
,syv
,SMSN
*3,0,-3);
188 void SMK_flame(int x0
,int y0
,int ox
,int oy
,int xr
,int yr
,int xv
,int yv
,int k
,int o
) {
193 xv
=xv
-(ox
<<8);yv
=yv
-(oy
<<8);
194 k
=max(abs(xv
),abs(yv
));
196 if(!burntm
) burntm
=Z_sound(burnsnd
,128);
197 for(i
=0;i
<=k
;i
+=200) {
198 x
=xv
*i
/k
+(x0
<<8)+sxr
[sr_r
]*xr
;
199 y
=yv
*i
/k
+(y0
<<8)+syr
[sr_r
]*yr
;
200 if(++sr_r
>=MAXSR
) sr_r
=0;
201 SMK_add(x
,y
,sxv
,syv
,FLSN
,1,o
);