Initial soap commit
This commit is contained in:
parent
fb408ab82b
commit
5aefd0cb01
@ -199,7 +199,8 @@
|
||||
#define PT_BRAN 146
|
||||
#define PT_WIND 147
|
||||
#define PT_H2 148
|
||||
#define PT_NUM 149
|
||||
#define PT_SOAP 149
|
||||
#define PT_NUM 150
|
||||
|
||||
#define R_TEMP 22
|
||||
#define MAX_TEMP 9999
|
||||
@ -299,6 +300,7 @@ int update_WATR(UPDATE_FUNC_ARGS);
|
||||
int update_WIFI(UPDATE_FUNC_ARGS);
|
||||
int update_WTRV(UPDATE_FUNC_ARGS);
|
||||
int update_YEST(UPDATE_FUNC_ARGS);
|
||||
int update_SOAP(UPDATE_FUNC_ARGS);
|
||||
int update_O2(UPDATE_FUNC_ARGS);
|
||||
int update_H2(UPDATE_FUNC_ARGS);
|
||||
|
||||
@ -316,6 +318,7 @@ struct particle
|
||||
float pavg[2];
|
||||
int flags;
|
||||
int tmp;
|
||||
int tmp2;
|
||||
};
|
||||
typedef struct particle particle;
|
||||
|
||||
@ -523,6 +526,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
|
||||
{"WIND", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, 0.0f, 40, "Drag tool", ST_NONE, ST_NONE, NULL},
|
||||
{"H2", PIXPACK(0x5070FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.10f, 0.00f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 251, "Combines with O2 to make WATR", ST_GAS, TYPE_GAS, &update_H2},
|
||||
{"SOAP", PIXPACK(0xF5F5DC), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Soap. Creates bubbles.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE, &update_SOAP},
|
||||
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description
|
||||
};
|
||||
|
||||
@ -687,6 +691,7 @@ static part_transition ptransitions[PT_NUM] =
|
||||
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* WIND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* H2 */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* SOAP */ {IPL, NT, IPH, NT, ITL, NT, ITL, NT},
|
||||
};
|
||||
#undef IPL
|
||||
#undef IPH
|
||||
|
108
src/elements/soap.c
Normal file
108
src/elements/soap.c
Normal file
@ -0,0 +1,108 @@
|
||||
#include <element.h>
|
||||
|
||||
int update_SOAP(UPDATE_FUNC_ARGS) {
|
||||
int r, rx, ry, wc;
|
||||
|
||||
wc = -1;
|
||||
|
||||
//0x01 - bubble on/off
|
||||
//0x02 - first mate yes/no
|
||||
//0x04 - second mate yes/no
|
||||
|
||||
if (pv[y/CELL][x/CELL]>0.5f)
|
||||
parts[i].ctype |= 0x01;
|
||||
|
||||
if (parts[i].ctype&0x01 == 0x01)
|
||||
{
|
||||
parts[i].vy -= 0.1f;
|
||||
|
||||
parts[i].vy *= 0.5f;
|
||||
parts[i].vx *= 0.5f;
|
||||
|
||||
if(parts[i].ctype&0x02 != 0x02)
|
||||
{
|
||||
for (rx=-2; rx<3; rx++)
|
||||
for (ry=-2; ry<3; ry++)
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
|
||||
if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&0x01==0x01)
|
||||
&& (parts[r>>8].ctype&0x04!=0x04))
|
||||
{
|
||||
if (parts[r>>8].ctype&0x02 == 0x02)
|
||||
{
|
||||
parts[i].tmp = r>>8;
|
||||
parts[r>>8].tmp2 = i;
|
||||
|
||||
parts[i].ctype |= 0x02;
|
||||
parts[r>>8].ctype |= 0x04;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].ctype&0x02!=0x02)
|
||||
{
|
||||
parts[i].tmp = r>>8;
|
||||
parts[r>>8].tmp2 = i;
|
||||
|
||||
parts[i].ctype |= 0x02;
|
||||
parts[r>>8].ctype |= 0x04;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float d, dx, dy;
|
||||
|
||||
dx = parts[i].x - parts[parts[i].tmp].x;
|
||||
dy = parts[i].y - parts[parts[i].tmp].y;
|
||||
|
||||
d = 9/(pow(dx, 2)+pow(dy, 2)+9)-0.5;
|
||||
|
||||
parts[parts[i].tmp].x -= dx*d;
|
||||
parts[parts[i].tmp].y -= dy*d;
|
||||
|
||||
parts[i].x += dx*d;
|
||||
parts[i].y += dy*d;
|
||||
|
||||
if ((parts[parts[i].tmp].ctype&0x02 == 0x02) && (parts[parts[i].tmp].ctype&0x01 == 0x01))
|
||||
{
|
||||
float d, dx, dy;
|
||||
int ii;
|
||||
|
||||
ii = parts[parts[i].tmp].tmp;
|
||||
|
||||
dx = parts[ii].x - parts[parts[i].tmp].x;
|
||||
dy = parts[ii].y - parts[parts[i].tmp].y;
|
||||
|
||||
d = 36/(pow(dx, 2)+pow(dy, 2)+36)-0.5;
|
||||
|
||||
parts[parts[i].tmp].x -= dx*d*0.5f;
|
||||
parts[parts[i].tmp].y -= dy*d*0.5f;
|
||||
|
||||
parts[ii].x += dx*d*0.5f;
|
||||
parts[ii].y += dy*d*0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (rx=-2; rx<3; rx++)
|
||||
for (ry=-2; ry<3; ry++)
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1495,6 +1495,13 @@ void draw_parts(pixel *vid)
|
||||
|
||||
nx = (int)(parts[i].x+0.5f);
|
||||
ny = (int)(parts[i].y+0.5f);
|
||||
|
||||
if (t==PT_SOAP)
|
||||
{
|
||||
//if ((parts[i].ctype&0x01 == 0x01) && (parts[i].ctype&0x02 == 0x02))
|
||||
// draw_line(vid, nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), 245, 245, 220, XRES+BARSIZE);
|
||||
}
|
||||
|
||||
if (cmode!=CM_HEAT)
|
||||
{
|
||||
if (t==PT_STKM) //Just draw head here
|
||||
|
@ -462,6 +462,14 @@ void kill_part(int i)//kills particle number i
|
||||
{
|
||||
ISSPAWN2 = 0;
|
||||
}
|
||||
if (parts[i].type == PT_SOAP)
|
||||
{
|
||||
if (parts[i].ctype&0x02 == 0x02)
|
||||
parts[parts[i].tmp].ctype ^= 0x04;
|
||||
|
||||
if (parts[i].ctype&0x04 == 0x04)
|
||||
parts[parts[i].tmp2].ctype ^= 0x02;
|
||||
}
|
||||
if (x>=0 && y>=0 && x<XRES && y<YRES) {
|
||||
if ((pmap[y][x]>>8)==i)
|
||||
pmap[y][x] = 0;
|
||||
@ -638,6 +646,7 @@ inline int create_part(int p, int x, int y, int t)//the function for creating a
|
||||
parts[i].ctype = 0;
|
||||
parts[i].temp = ptypes[t].heat;
|
||||
parts[i].tmp = 0;
|
||||
parts[i].tmp2 = 0;
|
||||
}
|
||||
//now set various properties that we want at spawn.
|
||||
if (t==PT_ACID)
|
||||
|
Reference in New Issue
Block a user