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
50 static init_t bl_ini
[MAXINI
],sp_ini
[MAXINI
];
51 static int bl_r
,sp_r
,sr_r
,sxr
[MAXSR
],syr
[MAXSR
];
57 for(i
=0;i
<MAXDOT
;++i
) {dot
[i
].t
=0;dot
[i
].o
.r
=0;dot
[i
].o
.h
=1;}
61 static void incldot(void) {
62 if(++ldot
>=MAXDOT
) ldot
=0;
65 void DOT_alloc(void) {
68 for(i
=0;i
<MAXINI
;++i
) {
69 bl_ini
[i
].xv
=myrand(BL_XV
*2+1)-BL_XV
;
70 bl_ini
[i
].yv
=-myrand(BL_YV
);
71 bl_ini
[i
].c
=0xB0+myrand(16);
72 bl_ini
[i
].t
=myrand(BL_MAXT
-BL_MINT
+1)+BL_MINT
;
73 sp_ini
[i
].xv
=myrand(SP_V
*2+1)-SP_V
;
74 sp_ini
[i
].yv
=myrand(SP_V
*2+1)-SP_V
;
75 sp_ini
[i
].c
=0xA0+myrand(6);
76 sp_ini
[i
].t
=myrand(SP_MAXT
-SP_MINT
+1)+SP_MINT
;
78 for(i
=0;i
<MAXSR
;++i
) {
79 sxr
[i
]=myrand(2*2+1)-2;
80 syr
[i
]=myrand(2*2+1)-2;
89 for(i
=0;i
<MAXDOT
;++i
) if(dot
[i
].t
) {
90 xv
=dot
[i
].o
.xv
+dot
[i
].o
.vx
;
91 yv
=dot
[i
].o
.yv
+dot
[i
].o
.vy
;
92 s
=Z_moveobj(&dot
[i
].o
);
93 if(dot
[i
].t
<254) --dot
[i
].t
;
94 if(s
&(Z_HITWATER
|Z_FALLOUT
)) {dot
[i
].t
=0;continue;}
98 if(!xv
) dot
[i
].o
.vx
=(rand()&1)?-1:1;
99 else dot
[i
].o
.vx
=Z_sign(dot
[i
].o
.vx
);
100 if(rand()%yv
==0) dot
[i
].o
.vx
*=2;
105 if(dot
[i
].t
>4 && dot
[i
].t
!=255) dot
[i
].t
=4;
108 dot
[i
].o
.vx
=Z_sign(xv
)*2;
109 dot
[i
].o
.yv
=Z_sign(dot
[i
].o
.yv
);
110 if(dot
[i
].o
.yv
>=0) if(rand()&3) --dot
[i
].o
.yv
;
111 if(dot
[i
].o
.yv
>=0) if(rand()&1) --dot
[i
].o
.yv
;
113 if(s
&Z_HITCEIL
) {dot
[i
].o
.xv
=0;dot
[i
].o
.yv
=(myrand(100))?-2:0;}
118 void DOT_add(int x
,int y
,char xv
,char yv
,byte c
,byte t
) {
121 if(!Z_canfit(x
,y
,0,1)) return;
123 dot
[i
].o
.x
=x
;dot
[i
].o
.y
=y
;
124 dot
[i
].o
.xv
=xv
;dot
[i
].o
.yv
=yv
;
125 dot
[i
].c
=c
;dot
[i
].t
=t
;
126 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
130 void DOT_blood(int x
,int y
,int xv
,int yv
,int n
) {
134 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
135 if(!Z_canfit(x
,y
,0,1)) continue;
137 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
138 dot
[i
].o
.xv
=bl_ini
[bl_r
].xv
+Z_dec(xv
,3);
139 dot
[i
].o
.yv
=bl_ini
[bl_r
].yv
+Z_dec(yv
,3)-3;
140 dot
[i
].c
=bl_ini
[bl_r
].c
;
142 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
143 if(++bl_r
>=MAXINI
) bl_r
=0;
144 if(++sr_r
>=MAXSR
) sr_r
=0;
149 void DOT_spark(int x
,int y
,int xv
,int yv
,int n
) {
153 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
154 if(!Z_canfit(x
,y
,0,1)) continue;
156 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
157 dot
[i
].o
.xv
=sp_ini
[sp_r
].xv
-xv
/4;
158 dot
[i
].o
.yv
=sp_ini
[sp_r
].yv
-yv
/4;
159 dot
[i
].c
=sp_ini
[sp_r
].c
;
160 dot
[i
].t
=sp_ini
[sp_r
].t
;
161 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
162 if(++sp_r
>=MAXINI
) sp_r
=0;
163 if(++sr_r
>=MAXSR
) sr_r
=0;
168 void DOT_water(int x
,int y
,int xv
,int yv
,int n
,int c
) {
170 static byte ct
[3]={0xC0,0x70,0xB0};
172 if(c
<0 || c
>=3) return;
175 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
176 if(!Z_canfit(x
,y
,0,1)) continue;
178 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
179 dot
[i
].o
.xv
=bl_ini
[bl_r
].xv
-Z_dec(xv
,3);
180 dot
[i
].o
.yv
=bl_ini
[bl_r
].yv
-abs(yv
);
181 dot
[i
].c
=bl_ini
[bl_r
].c
-0xB0+c
;
183 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
184 if(++bl_r
>=MAXINI
) bl_r
=0;
185 if(++sr_r
>=MAXSR
) sr_r
=0;