|
|
|
@ -41,34 +41,59 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
|
|
|
|
|
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
|
|
|
|
|
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[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[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[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[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[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[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[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[16] = pp;
|
|
|
|
|
|
|
|
|
@ -85,98 +110,70 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
|
|
|
|
|
playerp[25] = 0;
|
|
|
|
|
playerp[26] = 0;
|
|
|
|
|
|
|
|
|
|
//Go left
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
float gx, gy, dl, dr;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
playerp[26] = -2;
|
|
|
|
|
playerp[23] = -2;
|
|
|
|
|
if (dl>dr)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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[22] = -1;
|
|
|
|
|
playerp[19] = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])])
|
|
|
|
|
{
|
|
|
|
|
playerp[25] = -1;
|
|
|
|
|
playerp[26] = -1;
|
|
|
|
|
playerp[23] = -1;
|
|
|
|
|
playerp[25] = -3*gvy-3*gvx;
|
|
|
|
|
playerp[26] = 3*gvx-3*gvy;
|
|
|
|
|
playerp[19] = -gvy;
|
|
|
|
|
playerp[20] = gvx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Go right
|
|
|
|
|
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
|
|
|
|
if (((int)(playerp[0])&0x02) == 0x02 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
|
|
|
|
if (((int)(playerp[0])&0x02) == 0x02)
|
|
|
|
|
{
|
|
|
|
|
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
|
|
|
|
&& (r&0xFF) != PT_LNTG))
|
|
|
|
|
if (dl<dr)
|
|
|
|
|
{
|
|
|
|
|
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])])
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
|
|
|
|
|
{
|
|
|
|
|
playerp[21] = 3;
|
|
|
|
|
playerp[22] = -2;
|
|
|
|
|
playerp[19] = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pmap[(int)(playerp[16]-1)][(int)(playerp[15])])
|
|
|
|
|
{
|
|
|
|
|
playerp[25] = 3;
|
|
|
|
|
playerp[26] = -2;
|
|
|
|
|
playerp[23] = 2;
|
|
|
|
|
playerp[21] = 3*gvy-3*gvx;
|
|
|
|
|
playerp[22] = -3*gvx-3*gvy;
|
|
|
|
|
playerp[19] = gvy;
|
|
|
|
|
playerp[20] = -gvx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pmap[(int)(playerp[8]-1)][(int)(playerp[7])])
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
|
|
|
|
|
{
|
|
|
|
|
playerp[21] = 1;
|
|
|
|
|
playerp[22] = -1;
|
|
|
|
|
playerp[19] = 1;
|
|
|
|
|
playerp[25] = 3*gvy-3*gvx;
|
|
|
|
|
playerp[26] = -3*gvx-3*gvy;
|
|
|
|
|
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
|
|
|
|
|
if (((int)(playerp[0])&0x04) == 0x04 && (
|
|
|
|
|
(pmap[(int)(playerp[8]-0.5)][(int)(playerp[7])]&0xFF)>=PT_NUM ||
|
|
|
|
|
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 (((int)(playerp[0])&0x04) == 0x04 &&
|
|
|
|
|
(!eval_move(PT_DUST, playerp[7], playerp[8], NULL) || !eval_move(PT_DUST, playerp[15], playerp[16], NULL)))
|
|
|
|
|
{
|
|
|
|
|
if (pmap[(int)(playerp[8]-0.5)][(int)(playerp[7])] || pmap[(int)(playerp[16]-0.5)][(int)(playerp[15])])
|
|
|
|
|
{
|
|
|
|
|
parts[i].vy = -5;
|
|
|
|
|
playerp[22] -= 1;
|
|
|
|
|
playerp[26] -= 1;
|
|
|
|
|
}
|
|
|
|
|
parts[i].vy -= 4*gvy;
|
|
|
|
|
playerp[22] -= gvy;
|
|
|
|
|
playerp[26] -= gvy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Charge detector wall if foot inside
|
|
|
|
@ -243,7 +240,11 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
|
|
|
|
|
else
|
|
|
|
|
np = create_part(-1, rx, ry, playerp[2]);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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[12] += (playerp[12]-parts[i].y)*d;
|
|
|
|
|
|
|
|
|
|
//Side collisions checking
|
|
|
|
|
for (rx = -3; rx <= 3; rx++)
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
|
|
|
|
|
{
|
|
|
|
|
r = pmap[(int)(playerp[16]-2)][(int)(playerp[15]+rx)];
|
|
|
|
|
if (r && ((r&0xFF)>=PT_NUM || (ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID)))
|
|
|
|
|
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;
|
|
|
|
|
playerp[7] = playerp[9];
|
|
|
|
|
playerp[8] = playerp[10];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Collision checks
|
|
|
|
|
for (ry = -2-(int)parts[i].vy; ry<=0; ry++)
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
|
|
|
|
|
{
|
|
|
|
|
r = pmap[(int)(playerp[8]+ry)][(int)(playerp[7]+0.5)]; //This is to make coding more pleasant :-)
|
|
|
|
|
|
|
|
|
|
//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];
|
|
|
|
|
playerp[15] = playerp[17];
|
|
|
|
|
playerp[16] = playerp[18];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r = pmap[(int)(playerp[16]+ry)][(int)(playerp[15]+0.5)];
|
|
|
|
|
|
|
|
|
|
//For right leg
|
|
|
|
|
if (r && (r&0xFF)!=PT_STKM)
|
|
|
|
|
//This makes stick man "pop" from obstacles
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
|
|
|
|
|
{
|
|
|
|
|
if ((r&0xFF)<PT_NUM && (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG))
|
|
|
|
|
{
|
|
|
|
|
if (parts[i].y<(playerp[16]-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[16] += ry-1;
|
|
|
|
|
parts[i].vy -= 0.5*parts[i].vy*dt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
playerp[17] = playerp[15];
|
|
|
|
|
float t;
|
|
|
|
|
t = playerp[7]; playerp[7] = playerp[9]; playerp[9] = t;
|
|
|
|
|
t = playerp[8]; playerp[8] = playerp[10]; playerp[10] = t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If it falls too fast
|
|
|
|
|
if (parts[i].vy>=30)
|
|
|
|
|
if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
|
|
|
|
|
{
|
|
|
|
|
parts[i].y -= (10+ry)*dt;
|
|
|
|
|
parts[i].vy = -10*dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float t;
|
|
|
|
|
t = playerp[15]; playerp[15] = playerp[17]; playerp[17] = t;
|
|
|
|
|
t = playerp[16]; playerp[16] = playerp[18]; playerp[18] = t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
playerp[25] += 0.2;
|
|
|
|
|
float tvx, tvy;
|
|
|
|
|
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;
|
|
|
|
|
playerp[23] += 0.2;
|
|
|
|
|
float tvx, tvy;
|
|
|
|
|
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
|
|
|
|
|