summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorsavask <savask@yandex.ru>2011-10-23 08:22:31 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-26 14:36:00 (GMT)
commit03902ec9a4c60e53a7f80649bcf3a1158a20465e (patch)
tree537a5a55461e1596b2e6fa7843e9351d217f08c9 /src/elements
parent5652ecc5c20a6cce0745b20587ff4dfec8103ff3 (diff)
downloadpowder-03902ec9a4c60e53a7f80649bcf3a1158a20465e.zip
powder-03902ec9a4c60e53a7f80649bcf3a1158a20465e.tar.gz
Made a special structure for stick mans.
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/figh.c48
-rw-r--r--src/elements/ligh.c2
-rw-r--r--src/elements/prto.c4
-rw-r--r--src/elements/stkm.c364
-rw-r--r--src/elements/stkm2.c4
5 files changed, 211 insertions, 211 deletions
diff --git a/src/elements/figh.c b/src/elements/figh.c
index 74dcf14..fb172fb 100644
--- a/src/elements/figh.c
+++ b/src/elements/figh.c
@@ -2,40 +2,40 @@
int update_FIGH(UPDATE_FUNC_ARGS)
{
- float* figh = fighters[(unsigned char)parts[i].tmp];
+ playerst* figh = &fighters[(unsigned char)parts[i].tmp];
float tarx, tary;
parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man
//Set target cords
- if (player[27])
+ if (player.spwn)
{
- if (player2[27])
- if ((pow(player[5]-x, 2) + pow(player[6]-y, 2))<=
- (pow(player2[5]-x, 2) + pow(player2[6]-y, 2)))
+ if (player2.spwn)
+ if ((pow(player.legs[2]-x, 2) + pow(player.legs[3]-y, 2))<=
+ (pow(player2.legs[2]-x, 2) + pow(player2.legs[3]-y, 2)))
{
- tarx = player[5];
- tary = player[6];
+ tarx = player.legs[2];
+ tary = player.legs[3];
}
else
{
- tarx = player2[5];
- tary = player2[6];
+ tarx = player2.legs[2];
+ tary = player2.legs[3];
}
else
{
- tarx = player[5];
- tary = player[6];
+ tarx = player.legs[2];
+ tary = player.legs[3];
}
parts[i].tmp2 = 1;
}
else
- if (player2[27])
+ if (player2.spwn)
{
- tarx = player2[5];
- tary = player2[6];
+ tarx = player2.legs[2];
+ tary = player2.legs[3];
parts[i].tmp2 = 1;
}
@@ -45,29 +45,29 @@ int update_FIGH(UPDATE_FUNC_ARGS)
case 1:
if ((pow(tarx-x, 2) + pow(tary-y, 2))<600)
{
- if (figh[2] == PT_FIRE || figh[2] == PT_LIGH)
- figh[0] = (int)figh[0] | 0x08;
+ if (figh->elem == PT_FIRE || figh->elem == PT_LIGH)
+ figh->comm = (int)figh->comm | 0x08;
}
else
if (tarx<x)
{
- figh[0] = 0x01;
- if (!eval_move(PT_DUST, figh[7]-4, figh[8]-1, NULL) || !eval_move(PT_DUST, figh[15]-4, figh[16]-1, NULL))
- figh[0] = (int)figh[0] | 0x04;
+ figh->comm = 0x01;
+ if (!eval_move(PT_DUST, figh->legs[4]-4, figh->legs[5]-1, NULL) || !eval_move(PT_DUST, figh->legs[12]-4, figh->legs[13]-1, NULL))
+ figh->comm = (int)figh->comm | 0x04;
}
else
{
- figh[0] = 0x02;
- if (!eval_move(PT_DUST, figh[7]+4, figh[8]-1, NULL) || !eval_move(PT_DUST, figh[15]+4, figh[16]-1, NULL))
- figh[0] = (int)figh[0] | 0x04;
+ figh->comm = 0x02;
+ if (!eval_move(PT_DUST, figh->legs[4]+4, figh->legs[5]-1, NULL) || !eval_move(PT_DUST, figh->legs[12]+4, figh->legs[13]-1, NULL))
+ figh->comm = (int)figh->comm | 0x04;
}
break;
default:
- figh[0] = 0;
+ figh->comm = 0;
break;
}
- figh[1] = figh[0];
+ figh->pcomm = figh->comm;
run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS);
return 0;
diff --git a/src/elements/ligh.c b/src/elements/ligh.c
index bfbcd0d..9b20069 100644
--- a/src/elements/ligh.c
+++ b/src/elements/ligh.c
@@ -165,7 +165,7 @@ int update_LIGH(UPDATE_FUNC_ARGS)
}
if (ptypes[r&0xFF].hconduct)
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP);
- if (((r&0xFF)==PT_STKM && player[2]!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && player2[2]!=PT_LIGH))
+ if (((r&0xFF)==PT_STKM && player.elem!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && player2.elem!=PT_LIGH))
{
parts[r>>8].life-=powderful/100;
}
diff --git a/src/elements/prto.c b/src/elements/prto.c
index e86891a..dcbc53c 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -44,9 +44,9 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
else if (portalp[parts[i].tmp][randomness][nnx].type)
{
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
- player[27] = 0;
+ player.spwn = 0;
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
- player2[27] = 0;
+ player2.spwn = 0;
np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type);
if (np<0) continue;
parts[np] = portalp[parts[i].tmp][randomness][nnx];
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 0ac13e4..972bd86 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -1,7 +1,7 @@
#include <element.h>
int update_SPAWN(UPDATE_FUNC_ARGS) {
- if (!player[27])
+ if (!player.spwn)
create_part(-1, x, y, PT_STKM);
return 0;
@@ -9,11 +9,11 @@ int update_SPAWN(UPDATE_FUNC_ARGS) {
int update_STKM(UPDATE_FUNC_ARGS)
{
- run_stickman(player, UPDATE_FUNC_SUBCALL_ARGS);
+ run_stickman(&player, UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}
-int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
+int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
int r, rx, ry;
float pp, d;
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
@@ -21,8 +21,8 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
float gx, gy, dl, dr;
if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH)
- playerp[2] = parts[i].ctype;
- playerp[28]++;
+ playerp->elem = parts[i].ctype;
+ playerp->frames++;
//Tempirature handling
if (parts[i].temp<243)
@@ -31,14 +31,14 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
parts[i].temp += 1;
//Death
- if (parts[i].life<1 || (pv[y/CELL][x/CELL]>=4.5f && playerp[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
+ if (parts[i].life<1 || (pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
{
for (r=-2; r<=1; r++)
{
- create_part(-1, x+r, y-2, playerp[2]);
- create_part(-1, x+r+1, y+2, playerp[2]);
- create_part(-1, x-2, y+r+1, playerp[2]);
- create_part(-1, x+2, y+r, playerp[2]);
+ create_part(-1, x+r, y-2, playerp->elem);
+ create_part(-1, x+r+1, y+2, playerp->elem);
+ create_part(-1, x-2, y+r+1, playerp->elem);
+ create_part(-1, x+2, y+r, playerp->elem);
}
kill_part(i); //Kill him
return 1;
@@ -71,116 +71,116 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
parts[i].vy -= gvy*dt;
//Verlet integration
- 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;
- playerp[6] = playerp[4];
- playerp[4] = pp;
-
- 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]+gvy)*dt*dt;
- playerp[10] = playerp[8];
- playerp[8] = pp;
-
- 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;
- playerp[14] = playerp[12];
- playerp[12] = pp;
-
- 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]+gvy)*dt*dt;
- playerp[18] = playerp[16];
- playerp[16] = pp;
-
- //Setting acceleration to 0
- playerp[19] = 0;
- playerp[20] = 0;
-
- playerp[21] = 0;
- playerp[22] = 0;
-
- playerp[23] = 0;
- playerp[24] = 0;
-
- playerp[25] = 0;
- playerp[26] = 0;
-
- 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);
+ pp = 2*playerp->legs[0]-playerp->legs[2]+playerp->accs[0]*dt*dt;
+ playerp->legs[2] = playerp->legs[0];
+ playerp->legs[0] = pp;
+ pp = 2*playerp->legs[1]-playerp->legs[3]+playerp->accs[1]*dt*dt;
+ playerp->legs[3] = playerp->legs[1];
+ playerp->legs[1] = pp;
+
+ pp = 2*playerp->legs[4]-playerp->legs[6]+(playerp->accs[2]+gvx)*dt*dt;
+ playerp->legs[6] = playerp->legs[4];
+ playerp->legs[4] = pp;
+ pp = 2*playerp->legs[5]-playerp->legs[7]+(playerp->accs[3]+gvy)*dt*dt;
+ playerp->legs[7] = playerp->legs[5];
+ playerp->legs[5] = pp;
+
+ pp = 2*playerp->legs[8]-playerp->legs[10]+playerp->accs[4]*dt*dt;
+ playerp->legs[10] = playerp->legs[8];
+ playerp->legs[8] = pp;
+ pp = 2*playerp->legs[9]-playerp->legs[11]+playerp->accs[5]*dt*dt;
+ playerp->legs[11] = playerp->legs[9];
+ playerp->legs[9] = pp;
+
+ pp = 2*playerp->legs[12]-playerp->legs[14]+(playerp->accs[6]+gvx)*dt*dt;
+ playerp->legs[14] = playerp->legs[12];
+ playerp->legs[12] = pp;
+ pp = 2*playerp->legs[13]-playerp->legs[15]+(playerp->accs[7]+gvy)*dt*dt;
+ playerp->legs[15] = playerp->legs[13];
+ playerp->legs[13] = pp;
+
+ //Setting accseleration to 0
+ playerp->accs[0] = 0;
+ playerp->accs[1] = 0;
+
+ playerp->accs[2] = 0;
+ playerp->accs[3] = 0;
+
+ playerp->accs[4] = 0;
+ playerp->accs[5] = 0;
+
+ playerp->accs[6] = 0;
+ playerp->accs[7] = 0;
+
+ gx = (playerp->legs[4] + playerp->legs[12])/2 - gvy;
+ gy = (playerp->legs[5] + playerp->legs[13])/2 + gvx;
+ dl = pow(gx - playerp->legs[4], 2) + pow(gy - playerp->legs[5], 2);
+ dr = pow(gx - playerp->legs[12], 2) + pow(gy - playerp->legs[13], 2);
//Go left
- if (((int)(playerp[0])&0x01) == 0x01)
+ if (((int)(playerp->comm)&0x01) == 0x01)
{
if (dl>dr)
{
- if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL))
{
- playerp[21] = -3*gvy-3*gvx;
- playerp[22] = 3*gvx-3*gvy;
- playerp[19] = -gvy;
- playerp[20] = gvx;
+ playerp->accs[2] = -3*gvy-3*gvx;
+ playerp->accs[3] = 3*gvx-3*gvy;
+ playerp->accs[0] = -gvy;
+ playerp->accs[1] = gvx;
}
}
else
{
- if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL))
{
- playerp[25] = -3*gvy-3*gvx;
- playerp[26] = 3*gvx-3*gvy;
- playerp[19] = -gvy;
- playerp[20] = gvx;
+ playerp->accs[6] = -3*gvy-3*gvx;
+ playerp->accs[7] = 3*gvx-3*gvy;
+ playerp->accs[0] = -gvy;
+ playerp->accs[1] = gvx;
}
}
}
//Go right
- if (((int)(playerp[0])&0x02) == 0x02)
+ if (((int)(playerp->comm)&0x02) == 0x02)
{
if (dl<dr)
{
- if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL))
{
- playerp[21] = 3*gvy-3*gvx;
- playerp[22] = -3*gvx-3*gvy;
- playerp[19] = gvy;
- playerp[20] = -gvx;
+ playerp->accs[2] = 3*gvy-3*gvx;
+ playerp->accs[3] = -3*gvx-3*gvy;
+ playerp->accs[0] = gvy;
+ playerp->accs[1] = -gvx;
}
}
else
{
- if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL))
{
- playerp[25] = 3*gvy-3*gvx;
- playerp[26] = -3*gvx-3*gvy;
- playerp[19] = gvy;
- playerp[20] = -gvx;
+ playerp->accs[6] = 3*gvy-3*gvx;
+ playerp->accs[7] = -3*gvx-3*gvy;
+ playerp->accs[0] = gvy;
+ playerp->accs[1] = -gvx;
}
}
}
//Jump
- 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 (((int)(playerp->comm)&0x04) == 0x04 &&
+ (!eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL) || !eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL)))
{
parts[i].vy -= 4*gvy;
- playerp[22] -= gvy;
- playerp[26] -= gvy;
+ playerp->accs[3] -= gvy;
+ playerp->accs[7] -= gvy;
}
//Charge detector wall if foot inside
- if (bmap[(int)(playerp[8]+0.5)/CELL][(int)(playerp[7]+0.5)/CELL]==WL_DETECT)
- set_emap((int)playerp[7]/CELL, (int)playerp[8]/CELL);
- if (bmap[(int)(playerp[16]+0.5)/CELL][(int)(playerp[15]+0.5)/CELL]==WL_DETECT)
- set_emap((int)(playerp[15]+0.5)/CELL, (int)(playerp[16]+0.5)/CELL);
+ if (bmap[(int)(playerp->legs[5]+0.5)/CELL][(int)(playerp->legs[4]+0.5)/CELL]==WL_DETECT)
+ set_emap((int)playerp->legs[4]/CELL, (int)playerp->legs[5]/CELL);
+ if (bmap[(int)(playerp->legs[13]+0.5)/CELL][(int)(playerp->legs[12]+0.5)/CELL]==WL_DETECT)
+ set_emap((int)(playerp->legs[12]+0.5)/CELL, (int)(playerp->legs[13]+0.5)/CELL);
//Searching for particles near head
for (rx=-2; rx<3; rx++)
@@ -196,10 +196,10 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT)
{
- playerp[2] = r&0xFF; //Current element
+ playerp->elem = r&0xFF; //Current element
}
if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH)
- playerp[2] = PT_LIGH;
+ playerp->elem = PT_LIGH;
if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
{
if (parts[i].life<=95)
@@ -216,7 +216,7 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
kill_part(r>>8);
}
if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
- playerp[2] = SPC_AIR;
+ playerp->elem = SPC_AIR;
if ((r&0xFF)==PT_PRTI)
STKM_interact(playerp, i, rx, ry);
if (!parts[i].type)//STKM_interact may kill STKM
@@ -224,31 +224,31 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
}
//Head position
- rx = x + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01);
- ry = y - 3*(playerp[1] == 0);
+ rx = x + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01);
+ ry = y - 3*(playerp->pcomm == 0);
//Spawn
- if (((int)(playerp[0])&0x08) == 0x08)
+ if (((int)(playerp->comm)&0x08) == 0x08)
{
ry -= 2*(rand()%2)+1;
r = pmap[ry][rx];
if (ptypes[r&0xFF].state == ST_SOLID)
{
create_part(-1, rx, ry, PT_SPRK);
- playerp[28] = 0;
+ playerp->frames = 0;
}
else
{
int np = -1;
- if (playerp[2] == SPC_AIR)
- create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
- else if (playerp[2]==PT_LIGH && playerp[28]<30)//limit lightning creation rate
+ if (playerp->elem == SPC_AIR)
+ create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
+ else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
np = -1;
else
- np = create_part(-1, rx, ry, playerp[2]);
+ np = create_part(-1, rx, ry, playerp->elem);
if ( (np < NPART) && np>=0)
{
- if (playerp[2] == PT_PHOT)
+ if (playerp->elem == PT_PHOT)
{
int random = abs(rand()%3-1)*3;
if (random==0)
@@ -258,13 +258,13 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
else
{
parts[np].vy = 0;
- if (((int)playerp[1])&(0x01|0x02))
- parts[np].vx = (((((int)playerp[1])&0x02) == 0x02) - (((int)(playerp[1])&0x01) == 0x01))*random;
+ if (((int)playerp->pcomm)&(0x01|0x02))
+ parts[np].vx = (((((int)playerp->pcomm)&0x02) == 0x02) - (((int)(playerp->pcomm)&0x01) == 0x01))*random;
else
parts[np].vx = random;
}
}
- else if (playerp[2] == PT_LIGH)
+ else if (playerp->elem == PT_LIGH)
{
float angle;
int power = 100;
@@ -272,7 +272,7 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
angle = atan2(gvx, gvy)*180.0f/M_PI;
else
angle = rand()%360;
- if (((int)playerp[1])&0x01)
+ if (((int)playerp->comm)&0x01)
angle += 180;
if (angle>360)
angle-=360;
@@ -283,72 +283,72 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
parts[np].temp=parts[np].life*power/2.5;
parts[np].tmp2=1;
}
- else if (playerp[2] != SPC_AIR)
+ else if (playerp->elem != SPC_AIR)
{
- 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;
+ parts[np].vx -= -gvy*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01));
+ parts[np].vy -= gvx*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01));
+ parts[i].vx -= (ptypes[(int)playerp->elem].weight*parts[np].vx)/1000;
}
- playerp[28] = 0;
+ playerp->frames = 0;
}
}
}
//Simulation of joints
- d = 25/(pow((playerp[3]-playerp[7]), 2) + pow((playerp[4]-playerp[8]), 2)+25) - 0.5; //Fast distance
- playerp[7] -= (playerp[3]-playerp[7])*d;
- playerp[8] -= (playerp[4]-playerp[8])*d;
- playerp[3] += (playerp[3]-playerp[7])*d;
- playerp[4] += (playerp[4]-playerp[8])*d;
-
- d = 25/(pow((playerp[11]-playerp[15]), 2) + pow((playerp[12]-playerp[16]), 2)+25) - 0.5;
- playerp[15] -= (playerp[11]-playerp[15])*d;
- playerp[16] -= (playerp[12]-playerp[16])*d;
- playerp[11] += (playerp[11]-playerp[15])*d;
- playerp[12] += (playerp[12]-playerp[16])*d;
-
- d = 36/(pow((playerp[3]-parts[i].x), 2) + pow((playerp[4]-parts[i].y), 2)+36) - 0.5;
- parts[i].vx -= (playerp[3]-parts[i].x)*d;
- parts[i].vy -= (playerp[4]-parts[i].y)*d;
- playerp[3] += (playerp[3]-parts[i].x)*d;
- playerp[4] += (playerp[4]-parts[i].y)*d;
-
- d = 36/(pow((playerp[11]-parts[i].x), 2) + pow((playerp[12]-parts[i].y), 2)+36) - 0.5;
- parts[i].vx -= (playerp[11]-parts[i].x)*d;
- parts[i].vy -= (playerp[12]-parts[i].y)*d;
- playerp[11] += (playerp[11]-parts[i].x)*d;
- playerp[12] += (playerp[12]-parts[i].y)*d;
-
- if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
+ d = 25/(pow((playerp->legs[0]-playerp->legs[4]), 2) + pow((playerp->legs[1]-playerp->legs[5]), 2)+25) - 0.5; //Fast distance
+ playerp->legs[4] -= (playerp->legs[0]-playerp->legs[4])*d;
+ playerp->legs[5] -= (playerp->legs[1]-playerp->legs[5])*d;
+ playerp->legs[0] += (playerp->legs[0]-playerp->legs[4])*d;
+ playerp->legs[1] += (playerp->legs[1]-playerp->legs[5])*d;
+
+ d = 25/(pow((playerp->legs[8]-playerp->legs[12]), 2) + pow((playerp->legs[9]-playerp->legs[13]), 2)+25) - 0.5;
+ playerp->legs[12] -= (playerp->legs[8]-playerp->legs[12])*d;
+ playerp->legs[13] -= (playerp->legs[9]-playerp->legs[13])*d;
+ playerp->legs[8] += (playerp->legs[8]-playerp->legs[12])*d;
+ playerp->legs[9] += (playerp->legs[9]-playerp->legs[13])*d;
+
+ d = 36/(pow((playerp->legs[0]-parts[i].x), 2) + pow((playerp->legs[1]-parts[i].y), 2)+36) - 0.5;
+ parts[i].vx -= (playerp->legs[0]-parts[i].x)*d;
+ parts[i].vy -= (playerp->legs[1]-parts[i].y)*d;
+ playerp->legs[0] += (playerp->legs[0]-parts[i].x)*d;
+ playerp->legs[1] += (playerp->legs[1]-parts[i].y)*d;
+
+ d = 36/(pow((playerp->legs[8]-parts[i].x), 2) + pow((playerp->legs[9]-parts[i].y), 2)+36) - 0.5;
+ parts[i].vx -= (playerp->legs[8]-parts[i].x)*d;
+ parts[i].vy -= (playerp->legs[9]-parts[i].y)*d;
+ playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d;
+ playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d;
+
+ if (!eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL))
{
- playerp[7] = playerp[9];
- playerp[8] = playerp[10];
+ playerp->legs[4] = playerp->legs[6];
+ playerp->legs[5] = playerp->legs[7];
}
- if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL))
{
- playerp[15] = playerp[17];
- playerp[16] = playerp[18];
+ playerp->legs[12] = playerp->legs[14];
+ playerp->legs[13] = playerp->legs[15];
}
//This makes stick man "pop" from obstacles
- if (!eval_move(PT_DUST, playerp[7], playerp[8], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL))
{
float t;
- t = playerp[7]; playerp[7] = playerp[9]; playerp[9] = t;
- t = playerp[8]; playerp[8] = playerp[10]; playerp[10] = t;
+ t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t;
+ t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t;
}
- if (!eval_move(PT_DUST, playerp[15], playerp[16], NULL))
+ if (!eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL))
{
float t;
- t = playerp[15]; playerp[15] = playerp[17]; playerp[17] = t;
- t = playerp[16]; playerp[16] = playerp[18]; playerp[18] = t;
+ t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t;
+ t = playerp->legs[13]; playerp->legs[13] = playerp->legs[15]; playerp->legs[15] = t;
}
//Keeping legs distance
- if ((pow((playerp[7] - playerp[15]), 2) + pow((playerp[8]-playerp[16]), 2))<16)
+ if ((pow((playerp->legs[4] - playerp->legs[12]), 2) + pow((playerp->legs[5]-playerp->legs[13]), 2))<16)
{
float tvx, tvy;
tvx = -gvy;
@@ -356,15 +356,15 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
if (tvx || tvy)
{
- playerp[21] -= 0.2*tvx/hypot(tvx, tvy);
- playerp[22] -= 0.2*tvy/hypot(tvx, tvy);
+ playerp->accs[2] -= 0.2*tvx/hypot(tvx, tvy);
+ playerp->accs[3] -= 0.2*tvy/hypot(tvx, tvy);
- playerp[25] += 0.2*tvx/hypot(tvx, tvy);
- playerp[26] += 0.2*tvy/hypot(tvx, tvy);
+ playerp->accs[6] += 0.2*tvx/hypot(tvx, tvy);
+ playerp->accs[7] += 0.2*tvy/hypot(tvx, tvy);
}
}
- if ((pow((playerp[3] - playerp[11]), 2) + pow((playerp[4]-playerp[12]), 2))<16)
+ if ((pow((playerp->legs[0] - playerp->legs[8]), 2) + pow((playerp->legs[1]-playerp->legs[9]), 2))<16)
{
float tvx, tvy;
tvx = -gvy;
@@ -372,27 +372,27 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
if (tvx || tvy)
{
- playerp[19] -= 0.2*tvx/hypot(tvx, tvy);
- playerp[20] -= 0.2*tvy/hypot(tvx, tvy);
+ playerp->accs[0] -= 0.2*tvx/hypot(tvx, tvy);
+ playerp->accs[1] -= 0.2*tvy/hypot(tvx, tvy);
- playerp[23] += 0.2*tvx/hypot(tvx, tvy);
- playerp[24] += 0.2*tvy/hypot(tvx, tvy);
+ playerp->accs[4] += 0.2*tvx/hypot(tvx, tvy);
+ playerp->accs[5] += 0.2*tvy/hypot(tvx, tvy);
}
}
//If legs touch something
- STKM_interact(playerp, i, (int)(playerp[7]+0.5), (int)(playerp[8]+0.5));
- STKM_interact(playerp, i, (int)(playerp[15]+0.5), (int)(playerp[16]+0.5));
- STKM_interact(playerp, i, (int)(playerp[7]+0.5), (int)playerp[8]);
- STKM_interact(playerp, i, (int)(playerp[15]+0.5), (int)playerp[16]);
+ STKM_interact(playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5));
+ STKM_interact(playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5));
+ STKM_interact(playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]);
+ STKM_interact(playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]);
if (!parts[i].type)
return 1;
- parts[i].ctype = playerp[2];
+ parts[i].ctype = playerp->elem;
return 0;
}
-void STKM_interact(float* playerp, int i, int x, int y)
+void STKM_interact(playerst* playerp, int i, int x, int y)
{
int r;
if (x<0 || y<0 || x>=XRES || y>=YRES || !parts[i].type)
@@ -400,15 +400,15 @@ void STKM_interact(float* playerp, int i, int x, int y)
r = pmap[y][x];
if (r)
{
- if ((r&0xFF)==PT_SPRK && playerp[2]!=PT_LIGH) //If on charge
+ if ((r&0xFF)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge
{
parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
}
- if (ptypes[r&0xFF].hconduct && ((playerp[2]!=PT_LIGH && parts[r>>8].temp>=323) || parts[r>>8].temp<=243))
+ if (ptypes[r&0xFF].hconduct && ((playerp->elem!=PT_LIGH && parts[r>>8].temp>=323) || parts[r>>8].temp<=243))
{
parts[i].life -= 2;
- playerp[22] -= 1;
+ playerp->accs[3] -= 1;
}
if ((r&0xFF)==PT_ACID) //If on acid
@@ -431,37 +431,37 @@ void STKM_interact(float* playerp, int i, int x, int y)
{
portalp[parts[r>>8].tmp][count][nnx] = parts[i];
kill_part(i);
- playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
+ playerp->spwn = 1;//stop SPWN creating a new STKM while he is in portal
break;
}
}
}
}
-void STKM_init_legs(float* playerp, int i)
+void STKM_init_legs(playerst* playerp, int i)
{
int x, y;
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
- playerp[3] = x-1;
- playerp[4] = y+6;
- playerp[5] = x-1;
- playerp[6] = y+6;
-
- playerp[7] = x-3;
- playerp[8] = y+12;
- playerp[9] = x-3;
- playerp[10] = y+12;
-
- playerp[11] = x+1;
- playerp[12] = y+6;
- playerp[13] = x+1;
- playerp[14] = y+6;
-
- playerp[15] = x+3;
- playerp[16] = y+12;
- playerp[17] = x+3;
- playerp[18] = y+12;
+ playerp->legs[0] = x-1;
+ playerp->legs[1] = y+6;
+ playerp->legs[2] = x-1;
+ playerp->legs[3] = y+6;
+
+ playerp->legs[4] = x-3;
+ playerp->legs[5] = y+12;
+ playerp->legs[6] = x-3;
+ playerp->legs[7] = y+12;
+
+ playerp->legs[8] = x+1;
+ playerp->legs[9] = y+6;
+ playerp->legs[10] = x+1;
+ playerp->legs[11] = y+6;
+
+ playerp->legs[12] = x+3;
+ playerp->legs[13] = y+12;
+ playerp->legs[14] = x+3;
+ playerp->legs[15] = y+12;
}
diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c
index b1aeb20..e49f170 100644
--- a/src/elements/stkm2.c
+++ b/src/elements/stkm2.c
@@ -1,14 +1,14 @@
#include <element.h>
int update_SPAWN2(UPDATE_FUNC_ARGS) {
- if (!player2[27])
+ if (!player2.spwn)
create_part(-1, x, y, PT_STKM2);
return 0;
}
int update_STKM2(UPDATE_FUNC_ARGS) {
- run_stickman(player2, UPDATE_FUNC_SUBCALL_ARGS);
+ run_stickman(&player2, UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}