Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy

This commit is contained in:
Simon Robertshaw 2011-08-14 18:32:10 +01:00
commit dcd3af9440
7 changed files with 132 additions and 151 deletions

View File

@ -14,6 +14,8 @@ int update_O2(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_FIRE) if ((r&0xFF)==PT_FIRE)
{ {
parts[r>>8].temp+=(rand()/(RAND_MAX/100)); parts[r>>8].temp+=(rand()/(RAND_MAX/100));
if(parts[r>>8].tmp&0x01)
parts[r>>8].temp=3473;
parts[r>>8].tmp |= 2; parts[r>>8].tmp |= 2;
} }
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM)

View File

@ -18,7 +18,9 @@ int update_H2(UPDATE_FUNC_ARGS)
} }
if ((r&0xFF)==PT_FIRE) if ((r&0xFF)==PT_FIRE)
{ {
parts[r>>8].temp+=(rand()/(RAND_MAX/100)); parts[r>>8].temp=2473.15;
if(parts[r>>8].tmp&0x02)
parts[r>>8].temp=3473;
parts[r>>8].tmp |= 1; parts[r>>8].tmp |= 1;
} }
if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA) if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)

View File

@ -14,6 +14,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) {
t = PT_DSTW; t = PT_DSTW;
part_change_type(i,x,y,t); part_change_type(i,x,y,t);
parts[i].life = 0; parts[i].life = 0;
parts[i].ctype = PT_FIRE;
} }
else if (parts[i].temp<625) else if (parts[i].temp<625)
{ {

View File

@ -41,34 +41,59 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
return 1; return 1;
} }
parts[i].vy += -0.7*dt; //Head up! //Follow gravity
float gvx, gvy;
gvx = gvy = 0.0f;
switch (gravityMode)
{
default:
case 0:
gvy = 1;
break;
case 1:
gvy = gvx = 0.0f;
break;
case 2:
{
float gravd;
gravd = 0.01f - hypotf((parts[i].x - XCNTR), (parts[i].y - YCNTR));
gvx = ((float)(parts[i].x - XCNTR) / gravd);
gvy = ((float)(parts[i].y - YCNTR) / gravd);
}
}
gvx += gravx[(int)parts[i].y/CELL][(int)parts[i].x/CELL];
gvy += gravy[(int)parts[i].y/CELL][(int)parts[i].x/CELL];
parts[i].vx -= gvx*dt; //Head up!
parts[i].vy -= gvy*dt;
//Verlet integration //Verlet integration
pp = 2*playerp[3]-playerp[5]+playerp[19]*dt*dt;; pp = 2*playerp[3]-playerp[5]+playerp[19]*dt*dt;
playerp[5] = playerp[3]; playerp[5] = playerp[3];
playerp[3] = pp; playerp[3] = pp;
pp = 2*playerp[4]-playerp[6]+playerp[20]*dt*dt;; pp = 2*playerp[4]-playerp[6]+playerp[20]*dt*dt;
playerp[6] = playerp[4]; playerp[6] = playerp[4];
playerp[4] = pp; playerp[4] = pp;
pp = 2*playerp[7]-playerp[9]+playerp[21]*dt*dt;; pp = 2*playerp[7]-playerp[9]+(playerp[21]+gvx)*dt*dt;
playerp[9] = playerp[7]; playerp[9] = playerp[7];
playerp[7] = pp; playerp[7] = pp;
pp = 2*playerp[8]-playerp[10]+(playerp[22]+1)*dt*dt;; pp = 2*playerp[8]-playerp[10]+(playerp[22]+gvy)*dt*dt;
playerp[10] = playerp[8]; playerp[10] = playerp[8];
playerp[8] = pp; playerp[8] = pp;
pp = 2*playerp[11]-playerp[13]+playerp[23]*dt*dt;; pp = 2*playerp[11]-playerp[13]+playerp[23]*dt*dt;
playerp[13] = playerp[11]; playerp[13] = playerp[11];
playerp[11] = pp; playerp[11] = pp;
pp = 2*playerp[12]-playerp[14]+playerp[24]*dt*dt;; pp = 2*playerp[12]-playerp[14]+playerp[24]*dt*dt;
playerp[14] = playerp[12]; playerp[14] = playerp[12];
playerp[12] = pp; playerp[12] = pp;
pp = 2*playerp[15]-playerp[17]+playerp[25]*dt*dt;; pp = 2*playerp[15]-playerp[17]+(playerp[25]+gvx)*dt*dt;
playerp[17] = playerp[15]; playerp[17] = playerp[15];
playerp[15] = pp; playerp[15] = pp;
pp = 2*playerp[16]-playerp[18]+(playerp[26]+1)*dt*dt;; pp = 2*playerp[16]-playerp[18]+(playerp[26]+gvy)*dt*dt;
playerp[18] = playerp[16]; playerp[18] = playerp[16];
playerp[16] = pp; playerp[16] = pp;
@ -85,98 +110,70 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
playerp[25] = 0; playerp[25] = 0;
playerp[26] = 0; playerp[26] = 0;
//Go left float gx, gy, dl, dr;
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
if (((int)(playerp[0])&0x01) == 0x01 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
{
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
&& (r&0xFF) != PT_LNTG))
{
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])])
{
playerp[21] = -3;
playerp[22] = -2;
playerp[19] = -2;
}
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])]) gx = (playerp[7] + playerp[15])/2 - gvy;
gy = (playerp[8] + playerp[16])/2 + gvx;
dl = pow(gx - playerp[7], 2) + pow(gy - playerp[8], 2);
dr = pow(gx - playerp[15], 2) + pow(gy - playerp[16], 2);
//Go left
if (((int)(playerp[0])&0x01) == 0x01)
{ {
playerp[25] = -3; if (dl>dr)
playerp[26] = -2; {
playerp[23] = -2; if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
{
playerp[21] = -3*gvy-3*gvx;
playerp[22] = 3*gvx-3*gvy;
playerp[19] = -gvy;
playerp[20] = gvx;
} }
} }
else else
{ {
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])]) //It should move another way in liquids if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
{ {
playerp[21] = -1; playerp[25] = -3*gvy-3*gvx;
playerp[22] = -1; playerp[26] = 3*gvx-3*gvy;
playerp[19] = -1; playerp[19] = -gvy;
} playerp[20] = gvx;
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])])
{
playerp[25] = -1;
playerp[26] = -1;
playerp[23] = -1;
} }
} }
} }
//Go right //Go right
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]; if (((int)(playerp[0])&0x02) == 0x02)
if (((int)(playerp[0])&0x02) == 0x02 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
{ {
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID if (dl<dr)
&& (r&0xFF) != PT_LNTG))
{ {
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])]) if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
{ {
playerp[21] = 3; playerp[21] = 3*gvy-3*gvx;
playerp[22] = -2; playerp[22] = -3*gvx-3*gvy;
playerp[19] = 2; playerp[19] = gvy;
} playerp[20] = -gvx;
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])])
{
playerp[25] = 3;
playerp[26] = -2;
playerp[23] = 2;
} }
} }
else else
{ {
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])]) if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
{ {
playerp[21] = 1; playerp[25] = 3*gvy-3*gvx;
playerp[22] = -1; playerp[26] = -3*gvx-3*gvy;
playerp[19] = 1; playerp[19] = gvy;
playerp[20] = -gvx;
} }
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])])
{
playerp[25] = 1;
playerp[26] = -1;
playerp[23] = 1;
}
} }
} }
//Jump //Jump
if (((int)(playerp[0])&0x04) == 0x04 && ( if (((int)(playerp[0])&0x04) == 0x04 &&
(pmap[(int)(playerp[8]-0.5)][(int)(playerp[7])]&0xFF)>=PT_NUM || (!eval_move(PT_DUST, playerp[7], playerp[8], NULL) || !eval_move(PT_DUST, playerp[15], playerp[16], NULL)))
ptypes[pmap[(int)(playerp[8]-0.5)][(int)(playerp[7])]&0xFF].state != ST_GAS ||
(pmap[(int)(playerp[16]-0.5)][(int)(playerp[15])]&0xFF)>=PT_NUM ||
ptypes[pmap[(int)(playerp[16]-0.5)][(int)(playerp[15])]&0xFF].state != ST_GAS))
{ {
if (pmap[(int)(playerp[8]-0.5)][(int)(playerp[7])] || pmap[(int)(playerp[16]-0.5)][(int)(playerp[15])]) parts[i].vy -= 4*gvy;
{ playerp[22] -= gvy;
parts[i].vy = -5; playerp[26] -= gvy;
playerp[22] -= 1;
playerp[26] -= 1;
}
} }
//Charge detector wall if foot inside //Charge detector wall if foot inside
@ -243,7 +240,11 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
else else
np = create_part(-1, rx, ry, playerp[2]); np = create_part(-1, rx, ry, playerp[2]);
if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR) if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR)
parts[np].vx = parts[np].vx + 5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01); {
parts[np].vx -= -gvy*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
parts[np].vy -= gvx*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
parts[i].vx -= (ptypes[(int)playerp[2]].weight*parts[np].vx)/1000;
}
if ((np < NPART) && np>=0 && playerp[2] == PT_PHOT) if ((np < NPART) && np>=0 && playerp[2] == PT_PHOT)
{ {
int random = abs(rand()%3-1)*3; int random = abs(rand()%3-1)*3;
@ -290,91 +291,64 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
playerp[11] += (playerp[11]-parts[i].x)*d; playerp[11] += (playerp[11]-parts[i].x)*d;
playerp[12] += (playerp[12]-parts[i].y)*d; playerp[12] += (playerp[12]-parts[i].y)*d;
//Side collisions checking if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
for (rx = -3; rx <= 3; rx++)
{ {
r = pmap[(int)(playerp[16]-2)][(int)(playerp[15]+rx)]; playerp[7] = playerp[9];
if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID))) playerp[8] = playerp[10];
playerp[15] -= rx;
r = pmap[(int)(playerp[8]-2)][(int)(playerp[7]+rx)];
if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID)))
playerp[7] -= rx;
} }
//Collision checks if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
for (ry = -2-(int)parts[i].vy; ry<=0; ry++)
{ {
r = pmap[(int)(playerp[8]+ry)][(int)(playerp[7]+0.5)]; //This is to make coding more pleasant :-) playerp[15] = playerp[17];
playerp[16] = playerp[18];
//For left leg
if (r && (r&0xFF)!=PT_STKM)
{
if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) //Liquid checks
{
if (parts[i].y<(playerp[8]-10))
parts[i].vy = 1*dt;
else
parts[i].vy = 0;
if (abs(parts[i].vx)>1)
parts[i].vx *= 0.5*dt;
}
else
{
if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS)
{
playerp[8] += ry-1;
parts[i].vy -= 0.5*parts[i].vy*dt;
}
}
playerp[9] = playerp[7];
} }
r = pmap[(int)(playerp[16]+ry)][(int)(playerp[15]+0.5)]; //This makes stick man "pop" from obstacles
if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
//For right leg
if (r && (r&0xFF)!=PT_STKM)
{ {
if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)) float t;
{ t = playerp[7]; playerp[7] = playerp[9]; playerp[9] = t;
if (parts[i].y<(playerp[16]-10)) t = playerp[8]; playerp[8] = playerp[10]; playerp[10] = t;
parts[i].vy = 1*dt;
else
parts[i].vy = 0;
if (abs(parts[i].vx)>1)
parts[i].vx *= 0.5*dt;
}
else
{
if ((r&0xFF)>=PT_NUM || ptypes[r&0xFF].state != ST_GAS)
{
playerp[16] += ry-1;
parts[i].vy -= 0.5*parts[i].vy*dt;
}
}
playerp[17] = playerp[15];
} }
//If it falls too fast if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
if (parts[i].vy>=30)
{ {
parts[i].y -= (10+ry)*dt; float t;
parts[i].vy = -10*dt; t = playerp[15]; playerp[15] = playerp[17]; playerp[17] = t;
} t = playerp[16]; playerp[16] = playerp[18]; playerp[18] = t;
} }
//Keeping legs distance //Keeping legs distance
if (pow((playerp[7] - playerp[15]), 2)<16 && pow((playerp[8]-playerp[16]), 2)<1) if ((pow((playerp[7] - playerp[15]), 2) + pow((playerp[8]-playerp[16]), 2))<16)
{ {
playerp[21] -= 0.2; float tvx, tvy;
playerp[25] += 0.2; tvx = -gvy;
tvy = gvx;
if (tvx || tvy)
{
playerp[21] -= 0.2*tvx/hypot(tvx, tvy);
playerp[22] -= 0.2*tvy/hypot(tvx, tvy);
playerp[25] += 0.2*tvx/hypot(tvx, tvy);
playerp[26] += 0.2*tvy/hypot(tvx, tvy);
}
} }
if (pow((playerp[3] - playerp[11]), 2)<16 && pow((playerp[4]-playerp[12]), 2)<1) if ((pow((playerp[3] - playerp[11]), 2) + pow((playerp[4]-playerp[12]), 2))<16)
{ {
playerp[19] -= 0.2; float tvx, tvy;
playerp[23] += 0.2; tvx = -gvy;
tvy = gvx;
if (tvx || tvy)
{
playerp[19] -= 0.2*tvx/hypot(tvx, tvy);
playerp[20] -= 0.2*tvy/hypot(tvx, tvy);
playerp[23] += 0.2*tvx/hypot(tvx, tvy);
playerp[24] += 0.2*tvy/hypot(tvx, tvy);
}
} }
//If legs touch something //If legs touch something

View File

@ -15,5 +15,7 @@ int update_WTRV(UPDATE_FUNC_ARGS) {
parts[i].life = 4; parts[i].life = 4;
} }
} }
if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE)
parts[i].temp-=parts[i].temp/1000;
return 0; return 0;
} }

View File

@ -714,7 +714,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
j = PT_DUST;//goto corrupt; j = PT_DUST;//goto corrupt;
} }
gol[x][y]=0; gol[x][y]=0;
if (j)// && !(player[27] == 1 && j==PT_STKM)) if (j && !(player[27] == 1 && j==PT_STKM) && !(player2[27] == 1 && j==PT_STKM2)) //Don't comment this, it's needed
{ {
if (pmap[y][x] && (pmap[y][x]>>8)<NPART) if (pmap[y][x] && (pmap[y][x]>>8)<NPART)
{ {

View File

@ -1688,7 +1688,7 @@ void update_particles_i(pixel *vid, int start, int inc)
pGravX -= gravx[y/CELL][x/CELL]; pGravX -= gravx[y/CELL][x/CELL];
pGravY -= gravy[y/CELL][x/CELL]; pGravY -= gravy[y/CELL][x/CELL];
} }
else if(!(ptypes[t].properties & TYPE_SOLID)) else if(t!=PT_STKM && t!=PT_STKM2 && !(ptypes[t].properties & TYPE_SOLID))
{ {
pGravX += gravx[y/CELL][x/CELL]; pGravX += gravx[y/CELL][x/CELL];
pGravY += gravy[y/CELL][x/CELL]; pGravY += gravy[y/CELL][x/CELL];