From: Andriy Shinkarchuck Date: Sun, 24 Jul 2011 16:46:56 +0000 (+0300) Subject: dots.c dots.h moved to repo. Added license notification X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=commitdiff_plain;h=33ce454bb7737645bd61a2c282889ff71bb7b3a6 dots.c dots.h moved to repo. Added license notification --- diff --git a/dots.c b/dots.c new file mode 100755 index 0000000..ddb39a2 --- /dev/null +++ b/dots.c @@ -0,0 +1,223 @@ +/* + Copyright (C) Prikol Software 1996-1997 + Copyright (C) Aleksey Volynskov 1996-1997 + Copyright (C) 2011 + + This file is part of the Doom2D:Rembo project. + + Doom2D:Rembo is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + Doom2D:Rembo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see or + write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "glob.h" +//#include +#include +#include "files.h" +#include "memory.h" +#include "vga.h" +#include "error.h" +#include "keyb.h" +#include "sound.h" +#include "view.h" +#include "dots.h" +#include "misc.h" + +#define MAXINI 50 +#define MAXSR 20 + +#define BL_XV 4 +#define BL_YV 4 +#define BL_MINT 10 +#define BL_MAXT 14 + +#define SP_V 2 +#define SP_MINT 5 +#define SP_MAXT 7 + +extern byte z_dot; + +#pragma pack(1) +typedef struct{ + obj_t o; + byte c,t; +}dot_t; +#pragma pack() + +typedef struct{ + int xv,yv; + byte c,t; +}init_t; + +static dot_t dot[MAXDOT]; +static init_t bl_ini[MAXINI],sp_ini[MAXINI]; +static int bl_r,sp_r,sr_r,sxr[MAXSR],syr[MAXSR]; +static int ldot; + +void DOT_savegame(FILE* h) { + int i,n; + + for(i=n=0;i=MAXDOT) ldot=0; +} + +void DOT_alloc(void) { + int i; + + for(i=0;i2) { + if(!xv) dot[i].o.vx=(rand()&1)?-1:1; + else dot[i].o.vx=Z_sign(dot[i].o.vx); + if(rand()%yv==0) dot[i].o.vx*=2; + dot[i].o.yv=yv-2; + } + } + dot[i].o.xv=0; + if(dot[i].t>4 && dot[i].t!=255) dot[i].t=4; + } + if(s&Z_HITWALL) { + dot[i].o.vx=Z_sign(xv)*2; + dot[i].o.yv=Z_sign(dot[i].o.yv); + if(dot[i].o.yv>=0) if(rand()&3) --dot[i].o.yv; + if(dot[i].o.yv>=0) if(rand()&1) --dot[i].o.yv; + } + if(s&Z_HITCEIL) {dot[i].o.xv=0;dot[i].o.yv=(myrand(100))?-2:0;} + } + z_dot=0; +} + +void DOT_draw(void) { + int i; + + for(i=0;i=MAXINI) bl_r=0; + if(++sr_r>=MAXSR) sr_r=0; + incldot(); + } +} + +void DOT_spark(int x,int y,int xv,int yv,int n) { + int i,k,dx,dy; + + for(k=n;k;--k) { + dx=x+sxr[sr_r];dy=y+syr[sr_r]; + if(!Z_canfit(x,y,0,1)) continue; + i=ldot; + dot[i].o.x=dx;dot[i].o.y=dy; + dot[i].o.xv=sp_ini[sp_r].xv-xv/4; + dot[i].o.yv=sp_ini[sp_r].yv-yv/4; + dot[i].c=sp_ini[sp_r].c; + dot[i].t=sp_ini[sp_r].t; + dot[i].o.vx=dot[i].o.vy=0; + if(++sp_r>=MAXINI) sp_r=0; + if(++sr_r>=MAXSR) sr_r=0; + incldot(); + } +} + +void DOT_water(int x,int y,int xv,int yv,int n,int c) { + int i,k,dx,dy; + static byte ct[3]={0xC0,0x70,0xB0}; + + if(c<0 || c>=3) return; + c=ct[c]; + for(k=n;k;--k) { + dx=x+sxr[sr_r];dy=y+syr[sr_r]; + if(!Z_canfit(x,y,0,1)) continue; + i=ldot; + dot[i].o.x=dx;dot[i].o.y=dy; + dot[i].o.xv=bl_ini[bl_r].xv-Z_dec(xv,3); + dot[i].o.yv=bl_ini[bl_r].yv-abs(yv); + dot[i].c=bl_ini[bl_r].c-0xB0+c; + dot[i].t=254; + dot[i].o.vx=dot[i].o.vy=0; + if(++bl_r>=MAXINI) bl_r=0; + if(++sr_r>=MAXSR) sr_r=0; + incldot(); + } +} diff --git a/dots.h b/dots.h new file mode 100755 index 0000000..b5ac1d9 --- /dev/null +++ b/dots.h @@ -0,0 +1,34 @@ +/* + Copyright (C) Prikol Software 1996-1997 + Copyright (C) Aleksey Volynskov 1996-1997 + Copyright (C) 2011 + + This file is part of the Doom2D:Rembo project. + + Doom2D:Rembo is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + Doom2D:Rembo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see or + write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// Dots + +#define MAXDOT 400 + +void DOT_init(void); +void DOT_alloc(void); +void DOT_act(void); +void DOT_draw(void); +void DOT_add(int x,int y,char xv,char yv,byte color,byte time); +void DOT_blood(int,int,int,int,int); +void DOT_spark(int,int,int,int,int); +void DOT_water(int,int,int,int,int,int);