Fix merge

This commit is contained in:
Simon
2010-12-19 17:29:30 +00:00
7 changed files with 971 additions and 92 deletions

View File

@@ -28,6 +28,8 @@
#define YRES 384
#define NPART XRES*YRES
#define MAX_DISTANCE sqrt(pow(XRES, 2)+pow(YRES, 2))
#define MAXSIGNS 16
#define TAG_MAX 256
@@ -138,6 +140,12 @@ int GRID_MODE;
int VINE_MODE;
int DEBUG_MODE;
int GENERATION;
int isplayer2;
int playerspawn;
int player2spawn;
int death2;
int ISSPAWN1;
int ISSPAWN2;
extern sign signs[MAXSIGNS];
extern stamp stamps[STAMP_MAX];
extern int stamp_count;
@@ -147,7 +155,7 @@ extern char itc_msg[64];
extern int do_open;
extern int sys_pause;
extern int legacy_enable; //Used to disable new features such as heat, will be set by commandline or save.
extern int death, framerender;
extern int death, death2, framerender;
extern unsigned char last_major, last_minor, update_flag;

View File

@@ -29,4 +29,4 @@ short font_ptrs[] = {
0x0000, 0x000e, 0x001c, 0x002a, 0x0038, 0x0046, 0x0054, 0x0062, 0x0070, 0x007e, 0x008c, 0x009a, 0x00a8, 0x00b6, 0x00c4, 0x00d2, 0x00e0, 0x00ee, 0x00fc, 0x010a, 0x0118, 0x0126, 0x0134, 0x0142, 0x0150, 0x015e, 0x016c, 0x017a, 0x0188, 0x0196, 0x01a4, 0x01b2, 0x01c0, 0x01ce, 0x01d7, 0x01e5, 0x01f5, 0x0205, 0x0218, 0x0228, 0x0231, 0x023c, 0x0247, 0x0257, 0x0267, 0x0272, 0x0280, 0x0289, 0x0299, 0x02a9, 0x02b7, 0x02c7, 0x02d7, 0x02e7, 0x02f7, 0x0307, 0x0317, 0x0327, 0x0337, 0x0340, 0x034b, 0x035b, 0x036b, 0x037b, 0x038b, 0x03a0, 0x03b0, 0x03c0, 0x03d0, 0x03e0, 0x03f0, 0x0400, 0x0410, 0x0420, 0x042b, 0x043b, 0x044e, 0x045e, 0x0473, 0x0486, 0x0499, 0x04a9, 0x04bc, 0x04cc, 0x04dc, 0x04ec, 0x04ff, 0x050f, 0x0524, 0x0537, 0x0547, 0x055a, 0x0565, 0x0573, 0x057e, 0x0589, 0x0599, 0x05a2, 0x05b0, 0x05be, 0x05cc, 0x05da, 0x05e8, 0x05f3, 0x0601, 0x060f, 0x061a, 0x0625, 0x0633, 0x063e, 0x064e, 0x065c, 0x066a, 0x0678, 0x0686, 0x068f, 0x069d, 0x06a8, 0x06b6, 0x06c4, 0x06d4, 0x06e2, 0x06f0, 0x06fe, 0x0709, 0x070f, 0x071a, 0x072a, 0x0735, 0x074a, 0x0769, 0x0788, 0x07a2, 0x07c1, 0x07db, 0x07f5, 0x080f, 0x0829, 0x0843, 0x085d, 0x0877, 0x0896, 0x08a6, 0x08c0, 0x08da, 0x08f4, 0x090e, 0x0923, 0x0940, 0x095d, 0x097c, 0x099b, 0x09b3, 0x09cb, 0x09e3, 0x09fb, 0x0a13, 0x0a2b, 0x0a43, 0x0a5b, 0x0a73, 0x0a8b, 0x0aa3, 0x0abd, 0x0ada, 0x0af7, 0x0b0c, 0x0b26, 0x0b40, 0x0b5a, 0x0b74, 0x0b8c, 0x0b97, 0x0ba0, 0x0ba9, 0x0bb7, 0x0bc5, 0x0bd3, 0x0be1, 0x0bef, 0x0bfd, 0x0c0b, 0x0c19, 0x0c27, 0x0c35, 0x0c43, 0x0c4e, 0x0c57, 0x0c60, 0x0c6e, 0x0c7e, 0x0c8e, 0x0ca8, 0x0cc2, 0x0cdc, 0x0cf6, 0x0d10, 0x0d2a, 0x0d44, 0x0d5e, 0x0d78, 0x0d92, 0x0dac, 0x0dc6, 0x0de0, 0x0dfa, 0x0e14, 0x0e2e, 0x0e46, 0x0e60, 0x0e7a, 0x0e94, 0x0eae, 0x0ec8, 0x0ee2, 0x0ef2, 0x0f02, 0x0f12, 0x0f22, 0x0f32, 0x0f42, 0x0f52, 0x0f62, 0x0f72, 0x0f82, 0x0f92, 0x0fa2, 0x0fb2, 0x0fc2, 0x0fd2, 0x0fe2, 0x0ff2, 0x1002, 0x1012, 0x1022, 0x1032, 0x1042, 0x1052, 0x1062, 0x1072, 0x1082, 0x1092, 0x10a2, 0x10b2, 0x10c2, 0x10d2, 0x10e2, 0x10f2, 0x1102, 0x1112, 0x1122, 0x1132, 0x1142, 0x1152, 0x1162, 0x1172,
};
#endif
#endif
#endif

View File

@@ -137,7 +137,7 @@
#define PT_34 87
#define PT_LLIF 88
#define PT_STAN 89
#define PT_CRAC 90
#define PT_SPNG 90
#define PT_RIME 91
#define PT_FOG 92
#define PT_BCLN 93
@@ -164,8 +164,8 @@
#define PT_VINE 114
#define PT_INVIS 115
#define PT_EQUALVEL 116//all particles equal their velocities
#define PT_INST2 117//blank element, replace with something new, has to be here for numbering
#define PT_INST3 118//blank same as above
#define PT_SPAWN2 117//blank element, replace with something new, has to be here for numbering
#define PT_SPAWN 118//blank same as above
#define PT_SHLD1 119
#define PT_SHLD2 120
#define PT_SHLD3 121
@@ -175,7 +175,8 @@
#define PT_FILT 125
#define PT_ARAY 126
#define PT_BRAY 127
#define PT_NUM 128
#define PT_STKM2 128
#define PT_NUM 129
#define R_TEMP 22
#define MAX_TEMP 9999
@@ -395,7 +396,8 @@ static const part_type ptypes[PT_NUM] =
{"WIFI", PIXPACK(0x40A060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 2, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "Wireless transmitter, color coded.", TYPE_SOLID, NULL},
{"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", TYPE_SOLID, NULL},
{"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emmitter. Rays create points when they collide", TYPE_SOLID, NULL},
{"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL}
{"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL},
{"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL},
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description
};
@@ -492,7 +494,7 @@ static part_state pstates[PT_NUM] =
/* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* Crac */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 2730.0f},
/* SPNG */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 2730.0f},
/* RIME */ {ST_SOLID, PT_NONE, 0.0f, PT_WATR, 273.15f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* FOG */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* BCLN */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
@@ -519,8 +521,8 @@ static part_state pstates[PT_NUM] =
/* VINE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 573.0f},
/* INVS */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* EQVE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* INST2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* INST3*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* SPWN2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* SPAWN*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* SHLD1*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* SHLD2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* SHLD3*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
@@ -529,8 +531,9 @@ static part_state pstates[PT_NUM] =
/* WIFI */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* FILT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* ARAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* BRAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}
/* BRAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* STKM2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f},
};
static int grule[NGOL][9] =
{
@@ -573,13 +576,15 @@ static int lolzrule[9][9] =
{0,1,0,0,0,0,0,1,0},
{0,1,0,0,0,0,0,1,0},
};
int portal[8][8];
float portaltemp[8][8];
int portal[MAX_TEMP/100][8][8];
float portaltemp[MAX_TEMP/100][8][8];
int wireless[MAX_TEMP/100][2];
extern int isplayer;
extern float player[27];
extern float player2[27];
extern particle *parts;
extern particle *cb_parts;
@@ -636,6 +641,8 @@ void update_particles_i(pixel *vid, int start, int inc);
void update_particles(pixel *vid);
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert);
void clear_area(int area_x, int area_y, int area_w, int area_h);
void create_box(int x1, int y1, int x2, int y2, int c);

View File

@@ -1402,6 +1402,31 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
else if(t==PT_STKM2) //Just draw head here
{
char buff[10]; //Buffer for HP
if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
{
sprintf(buff, "%3d", parts[i].life); //Show HP
drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
}
for(r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p
{
s = XRES+BARSIZE;
vid[(ny-2)*s+nx+r] = ptypes[(int)player2[2]].pcolors;
vid[(ny+2)*s+nx+r+1] = ptypes[(int)player2[2]].pcolors;
vid[(ny+r+1)*s+nx-2] = ptypes[(int)player2[2]].pcolors;
vid[(ny+r)*s+nx+2] = ptypes[(int)player2[2]].pcolors;
}
draw_line(vid , nx, ny+3, player2[3], player2[4], 100, 100, 255, s);
draw_line(vid , player2[3], player2[4], player2[7], player2[8], 100, 100, 255, s);
draw_line(vid , nx, ny+3, player2[11], player2[12], 100, 100, 255, s);
draw_line(vid , player2[11], player2[12], player2[15], player2[16], 100, 100, 255, s);
isplayer2 = 1; //It's a secret. Tssss...
}
if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes
{
if(t==PT_PHOT)
@@ -1434,25 +1459,48 @@ void draw_parts(pixel *vid)
}
else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
{
float frequency = 0.05;
int q = parts[i].temp;
cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
if(cr>=255)
if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
{
float frequency = 0.00146;
int q = parts[i].temp-473;
cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors);
if(cr>=255)
cr = 255;
if(cg>=255)
if(cg>=255)
cg = 255;
if(cb>=255)
if(cb>=255)
cb = 255;
if(cr<=0)
if(cr<=0)
cr = 0;
if(cg<=0)
if(cg<=0)
cg = 0;
if(cb<=0)
if(cb<=0)
cb = 0;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
else
{
float frequency = 0.05;
int q = parts[i].temp-40;
cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
if(cr>=255)
cr = 255;
if(cg>=255)
cg = 255;
if(cb>=255)
cb = 255;
if(cr<=0)
cr = 0;
if(cg<=0)
cg = 0;
if(cb<=0)
cb = 0;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
}
else if(t==PT_MWAX&&cmode == CM_FANCY)
@@ -1471,7 +1519,7 @@ void draw_parts(pixel *vid)
}
}
else if(t==PT_CRAC)
else if(t==PT_SPNG)
{
cr = PIXR(ptypes[t].pcolors) - parts[i].life*15;
cg = PIXG(ptypes[t].pcolors) - parts[i].life*15;
@@ -1623,7 +1671,28 @@ void draw_parts(pixel *vid)
cr = cr>255?255:cr;
cg = cg>255?255:cg;
cb = cb>255?255:cb;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
fg = 0;
fb = 0;
fr = 0;
fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
x = nx/CELL;
y = ny/CELL;
fg += fire_g[y][x];
if(fg > 255) fg = 255;
fire_g[y][x] = fg;
fb += fire_b[y][x];
if(fb > 255) fb = 255;
fire_b[y][x] = fb;
fr += fire_r[y][x];
if(fr > 255) fr = 255;
fire_r[y][x] = fr;
}
else
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
else if(t==PT_PIPE)
{
@@ -2535,6 +2604,31 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
else if(t==PT_STKM2) //Stick man should be visible in heat mode
{
char buff[10]; //Buffer for HP
if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
{
sprintf(buff, "%3d", parts[i].life); //Show HP
drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255);
}
for(r=-2; r<=1; r++)
{
s = XRES+BARSIZE;
vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B);
vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B);
vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B);
vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B);
}
draw_line(vid , nx, ny+3, player2[3], player2[4], R, G, B, s);
draw_line(vid , player2[3], player2[4], player2[7], player2[8], R, G, B, s);
draw_line(vid , nx, ny+3, player2[11], player2[12], R, G, B, s);
draw_line(vid , player2[11], player2[12], player2[15], player2[16], R, G, B, s);
isplayer2 = 1; //It's a secret. Tssss...
}
else
{
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B);
@@ -2963,6 +3057,21 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
}
else if(j==PT_STKM2)
{
//Stickman drawing
for(k=-2; k<=1; k++)
{
fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178);
fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178);
fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178);
fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178);
}
draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w);
draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w);
draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
}
else
fb[y*w+x] = ptypes[j].pcolors;
}

View File

@@ -1749,6 +1749,23 @@ int sdl_poll(void)
{
player[0] = (int)(player[0])|0x04; //Jump command
}
if(event.key.keysym.sym == SDLK_d)
{
player2[0] = (int)(player2[0])|0x02; //Go right command
}
if(event.key.keysym.sym == SDLK_a)
{
player2[0] = (int)(player2[0])|0x01; //Go left command
}
if(event.key.keysym.sym == SDLK_s && ((int)(player2[0])&0x08)!=0x08)
{
player2[0] = (int)(player2[0])|0x08; //Go left command
}
if(event.key.keysym.sym == SDLK_w && ((int)(player2[0])&0x04)!=0x04)
{
player2[0] = (int)(player2[0])|0x04; //Jump command
}
break;
case SDL_KEYUP:
@@ -1769,6 +1786,20 @@ int sdl_poll(void)
{
player[0] = (int)(player[0])&7;
}
if(event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a)
{
player2[1] = player2[0]; //Saving last movement
player2[0] = (int)(player2[0])&12; //Stop command
}
if(event.key.keysym.sym == SDLK_w)
{
player2[0] = (int)(player2[0])&11;
}
if(event.key.keysym.sym == SDLK_s)
{
player2[0] = (int)(player2[0])&7;
}
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.button == SDL_BUTTON_WHEELUP)

View File

@@ -636,6 +636,31 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
player[18] = parts[i].y+12;
}
if(parts[i].type == PT_STKM2)
{
//player[2] = PT_DUST;
player2[3] = parts[i].x-1; //Setting legs positions
player2[4] = parts[i].y+6;
player2[5] = parts[i].x-1;
player2[6] = parts[i].y+6;
player2[7] = parts[i].x-3;
player2[8] = parts[i].y+12;
player2[9] = parts[i].x-3;
player2[10] = parts[i].y+12;
player2[11] = parts[i].x+1;
player2[12] = parts[i].y+6;
player2[13] = parts[i].x+1;
player2[14] = parts[i].y+6;
player2[15] = parts[i].x+3;
player2[16] = parts[i].y+12;
player2[17] = parts[i].x+3;
player2[18] = parts[i].y+12;
}
}
else
p += 2;
@@ -1292,11 +1317,11 @@ int main(int argc, char *argv[])
break;
}
}
if(sdl_key=='d' && isplayer)
{
death = 1;
//death = !(death);
}
//if(sdl_key=='d' && isplayer)
//{
// death = 1;
// //death = !(death);
//}
if(sdl_key=='f')
{
framerender = 1;
@@ -1332,7 +1357,7 @@ int main(int argc, char *argv[])
free(load_data);
}
}
if(sdl_key=='s')
if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL)))
{
if(it > 50)
it = 50;
@@ -1462,10 +1487,8 @@ int main(int argc, char *argv[])
bsy = 0;
}
}
if(sdl_key=='d')
if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)))
DEBUG_MODE = !DEBUG_MODE;
if(sdl_key=='r')
GENERATION = 0;
if(sdl_key=='i')
{
int nx, ny;
@@ -1479,10 +1502,15 @@ int main(int argc, char *argv[])
}
if((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
active_menu = 11;
if(sdl_key==SDLK_INSERT)
if(sdl_key==SDLK_INSERT || sdl_key==SDLK_BACKQUOTE)
REPLACE_MODE = !REPLACE_MODE;
if(sdl_key=='g')
GRID_MODE = (GRID_MODE+1)%10;
{
if(sdl_mod & (KMOD_SHIFT))
GRID_MODE = (GRID_MODE+9)%10;
else
GRID_MODE = (GRID_MODE+1)%10;
}
if(sdl_key=='t')
VINE_MODE = !VINE_MODE;
if(sdl_key==SDLK_SPACE)
@@ -1508,6 +1536,18 @@ int main(int argc, char *argv[])
}
}
}
if(sdl_key=='r'&&(sdl_mod & (KMOD_CTRL))&&(sdl_mod & (KMOD_SHIFT)))
{
save_mode = 1;
copy_mode = 4;//invert
}
else if(sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
save_mode = 1;
copy_mode = 3;//rotate
}
else if(sdl_key=='r')
GENERATION = 0;
if(sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
save_mode = 1;
@@ -1864,6 +1904,22 @@ int main(int argc, char *argv[])
copy_mode = 0;
clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
}
else if(copy_mode==3)//rotation
{
if(save_h>save_w)
save_w = save_h;
rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now
save_mode = 0;
copy_mode = 0;
}
else if(copy_mode==4)//invertion
{
if(save_h>save_w)
save_w = save_h;
rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now
save_mode = 0;
copy_mode = 0;
}
else
{
stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
@@ -2144,7 +2200,14 @@ int main(int argc, char *argv[])
if(save_mode)
{
xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
if(copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles
{
if(save_h>save_w)
save_w = save_h;
xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL);
}
else
xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
da = 51;
db = 269;
}
@@ -2273,7 +2336,7 @@ int main(int argc, char *argv[])
sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS);
#else
if(DEBUG_MODE)
sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION);
sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION);
else
sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB);
#endif
@@ -2315,6 +2378,13 @@ int main(int argc, char *argv[])
else
player[2] = PT_DUST;
}
if(isplayer2==0)
{
if(ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT)
player2[2] = sr;
else
player2[2] = PT_DUST;
}
}

View File

@@ -7,6 +7,7 @@
int isplayer = 0;
float player[27]; //[0] is a command cell, [3]-[18] are legs positions, [19] is index, [19]-[26] are accelerations
float player2[27];
particle *parts;
particle *cb_parts;
@@ -83,6 +84,8 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(pt==PT_STKM) //Stick man's head shouldn't collide
return 2;
if(pt==PT_STKM2) //Stick man's head shouldn't collide
return 2;
if((pt==PT_BIZR||pt==PT_BIZRG)&&(r&0xFF)==PT_FILT)
return 2;
if(bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE)
@@ -182,11 +185,31 @@ int try_move(int i, int x, int y, int nx, int ny)
if((r&0xFF)==PT_VOID)
{
if(parts[i].type == PT_STKM)
{
death = 1;
isplayer = 0;
}
if(parts[i].type == PT_STKM2)
{
death2 = 1;
isplayer2 = 0;
}
parts[i].type=PT_NONE;
return 0;
}
if((r&0xFF)==PT_BHOL)
{
if(parts[i].type == PT_STKM)
{
death = 1;
isplayer = 0;
}
if(parts[i].type == PT_STKM2)
{
death2 = 1;
isplayer2 = 0;
}
parts[i].type=PT_NONE;
if(!legacy_enable)
{
@@ -367,7 +390,24 @@ void kill_part(int i)
if(parts[i].type != PT_PHOT) {
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
if(parts[i].type == PT_STKM)
{
death = 1;
isplayer = 0;
}
if(parts[i].type == PT_STKM2)
{
death2 = 1;
isplayer2 = 0;
}
if(parts[i].type == PT_SPAWN)
{
ISSPAWN1 = 0;
}
if(parts[i].type == PT_SPAWN2)
{
ISSPAWN2 = 0;
}
if(x>=0 && y>=0 && x<XRES && y<YRES)
pmap[y][x] = 0;
}
@@ -467,11 +507,31 @@ inline int create_part(int p, int x, int y, int t)
pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK;
return pmap[y][x]>>8;
}
if(p==-1)
if(t==PT_SPAWN&&ISSPAWN1)
return -1;
if(t==PT_SPAWN2&&ISSPAWN2)
return -1;
if(p==-1)//creating from anything but brush
{
if(pmap[y][x])
if((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
if(t!=PT_STKM&&t!=PT_STKM2)
return -1;
if(pfree == -1)
return -1;
i = pfree;
pfree = parts[i].life;
}
else if(p==-2)//creating from brush
{
if(pmap[y][x])
{
if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN))
{
parts[pmap[y][x]>>8].ctype = t;
}
return -1;
}
if(pfree == -1)
return -1;
i = pfree;
@@ -484,7 +544,7 @@ inline int create_part(int p, int x, int y, int t)
{
parts[i].pavg[1] = pv[y/CELL][x/CELL];
}
if(t!=PT_STKM)
if(t!=PT_STKM&&t!=PT_STKM2)
{
parts[i].x = (float)x;
parts[i].y = (float)y;
@@ -562,13 +622,26 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
}
if(t!=PT_STKM)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
if(t==PT_BIZR||t==PT_BIZRG)
parts[i].ctype = 0x47FFFF;
if(t!=PT_STKM&&t!=PT_STKM2)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill
pmap[y][x] = t|(i<<8);
else if(t==PT_STKM)
{
if(isplayer==0)
{
if(pmap[y][x]&0xFF==PT_SPAWN)
{
parts[pmap[y][x]>>8].type = PT_STKM;
parts[pmap[y][x]>>8].vx = 0;
parts[pmap[y][x]>>8].vy = 0;
parts[pmap[y][x]>>8].life = 100;
parts[pmap[y][x]>>8].ctype = 0;
parts[pmap[y][x]>>8].temp = ptypes[t].heat;
}
else
{
parts[i].x = (float)x;
parts[i].y = (float)y;
parts[i].type = PT_STKM;
@@ -577,6 +650,7 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].temp = ptypes[t].heat;
}
@@ -602,6 +676,63 @@ inline int create_part(int p, int x, int y, int t)
isplayer = 1;
}
//kill_part(playerspawn);
create_part(-1,x,y,PT_SPAWN);
ISSPAWN1 = 1;
}
else if(t==PT_STKM2)
{
if(isplayer2==0)
{
if(pmap[y][x]&0xFF==PT_SPAWN2)
{
parts[pmap[y][x]>>8].type = PT_STKM2;
parts[pmap[y][x]>>8].vx = 0;
parts[pmap[y][x]>>8].vy = 0;
parts[pmap[y][x]>>8].life = 100;
parts[pmap[y][x]>>8].ctype = 0;
parts[pmap[y][x]>>8].temp = ptypes[t].heat;
}
else
{
parts[i].x = (float)x;
parts[i].y = (float)y;
parts[i].type = PT_STKM2;
parts[i].vx = 0;
parts[i].vy = 0;
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].temp = ptypes[t].heat;
}
player2[3] = x-1; //Setting legs positions
player2[4] = y+6;
player2[5] = x-1;
player2[6] = y+6;
player2[7] = x-3;
player2[8] = y+12;
player2[9] = x-3;
player2[10] = y+12;
player2[11] = x+1;
player2[12] = y+6;
player2[13] = x+1;
player2[14] = y+6;
player2[15] = x+3;
player2[16] = y+12;
player2[17] = x+3;
player2[18] = y+12;
isplayer2 = 1;
}
//kill_part(player2spawn);
create_part(-1,x,y,PT_SPAWN2);
ISSPAWN2 = 1;
}
return i;
@@ -852,7 +983,7 @@ inline int parts_avg(int ci, int ni,int t)
int nearest_part(int ci, int t)
{
int distance = sqrt(pow(XRES, 2)+pow(YRES, 2));
int distance = MAX_DISTANCE;
int ndistance = 0;
int id = -1;
int i = 0;
@@ -1146,7 +1277,7 @@ void update_particles_i(pixel *vid, int start, int inc)
//printf("parts[%d].type: %d\n", i, parts[i].type);
if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_CRAC && t!=PT_DEUT)
if(parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT)
{
if(!(parts[i].life==10&&(parts[i].type==PT_LCRY||parts[i].type==PT_PCLN||parts[i].type==PT_HSWC||parts[i].type==PT_PUMP)))
parts[i].life--;
@@ -1192,7 +1323,7 @@ void update_particles_i(pixel *vid, int start, int inc)
(bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWGAS && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) ||
(bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) ||
(bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM)))
(bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2)))
{
kill_part(i);
continue;
@@ -1373,12 +1504,18 @@ void update_particles_i(pixel *vid, int start, int inc)
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f)
{
t = parts[i].type = PT_FIRE;
parts[i].life = rand()%50+120;
}
}
if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f) // Only way I know to make it
t = parts[i].type = PT_FIRE; // combust under pressure.
if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f)
{ // Only way I know to make it
t = parts[i].type = PT_FIRE; // combust under pressure.
parts[i].life = rand()%50+120;
}
if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
@@ -1560,9 +1697,15 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else
{
t = parts[i].type = pstates[t].gas;
if(t!=PT_BIZRS)
if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
{
t = parts[i].type = pstates[t].gas;
}
else{
t = parts[i].type = pstates[t].gas;
pv[y/CELL][x/CELL] += 0.50f;
}
if(t==PT_FIRE)
parts[i].life = rand()%50+120;
if(t==PT_HFLM)
@@ -2310,6 +2453,11 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].type = PT_FWRK;
if((r&0xFF)==PT_FWRK && 5>(rand()%100))
parts[r>>8].ctype = PT_DUST;
if((r&0xFF)==PT_ACID && 5>(rand()%100))
{
parts[r>>8].type = PT_ISOZ;
parts[r>>8].life = 0;
}
/*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM &&
(ptypes[parts[r>>8].type-1].menusection==SC_LIQUID||
ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE||
@@ -2371,6 +2519,23 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
else if(t==PT_GLOW)
{
for(nx=-1; nx<2; nx++)
for(ny=-1; ny<2; ny++)
if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
{
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
if(parts[r>>8].type==PT_WATR&&5>(rand()%2000))
{
t = parts[i].type = PT_NONE;
parts[r>>8].type = PT_DEUT;
parts[r>>8].life = 10;
}
}
}
else if(t==PT_MORT) {
create_part(-1, x, y-1, PT_SMKE);
}
@@ -2386,7 +2551,7 @@ void update_particles_i(pixel *vid, int start, int inc)
ISLOLZ=1;
else if(t==PT_GRAV)
ISGRAV=1;
else if(t==PT_CRAC)
else if(t==PT_SPNG)
{
if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3)
{
@@ -2609,15 +2774,11 @@ void update_particles_i(pixel *vid, int start, int inc)
continue;
if(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
{
t = parts[i].type = parts[r>>8].type;
parts[i].ctype = parts[r>>8].ctype;
parts[i].life = parts[r>>8].life;
parts[i].tmp = parts[r>>8].tmp;
parts[i].temp = parts[r>>8].temp;
parts[i].vx = parts[r>>8].vx;
parts[i].vy = parts[r>>8].vy;
parts[r>>8].type = PT_WARP;
parts[r>>8].life = rand()%90+1;
parts[i].x = parts[r>>8].x;
parts[i].y = parts[r>>8].y;
parts[r>>8].x = x;
parts[r>>8].y = y;
parts[i].life += 4;
trade = 5;
}
}
@@ -2898,7 +3059,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(t==PT_PRTI)
{
int count =0;
int temprange = 100;
int count =0;
for( temp = 0; temp < MAX_TEMP; temp += temprange)
if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
parts[i].tmp = temp/100;
for(ny=-1; ny<2; ny++)
for(nx=-1; nx<2; nx++)
if(x+nx>=0 && y+ny>0 &&
@@ -2910,10 +3075,10 @@ void update_particles_i(pixel *vid, int start, int inc)
continue;
if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
for( nnx=0;nnx<8;nnx++)
if(!portal[count-1][nnx])
if(!portal[parts[i].tmp][count-1][nnx])
{
portal[count-1][nnx] = parts[r>>8].type;
portaltemp[count-1][nnx] = parts[r>>8].temp;
portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
if(parts[r>>8].type==PT_SPRK)
parts[r>>8].type = parts[r>>8].ctype;
else
@@ -2924,7 +3089,11 @@ void update_particles_i(pixel *vid, int start, int inc)
}
else if(t==PT_PRTO)
{
int count = 0;
int temprange = 100;
int count = 0;
for( temp = 0; temp < MAX_TEMP; temp += temprange)
if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
parts[i].tmp = temp/100;
for(ny=1; ny>-2; ny--)
for(nx=1; nx>-2; nx--)
if(x+nx>=0 && y+ny>0 &&
@@ -2943,26 +3112,26 @@ void update_particles_i(pixel *vid, int start, int inc)
randomness=1;
if(randomness>8)
randomness=8;
if(portal[randomness-1][nnx]==PT_SPRK)//todo. make it look better
if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
{
create_part(-1,x+1,y,portal[randomness-1][nnx]);
create_part(-1,x+1,y+1,portal[randomness-1][nnx]);
create_part(-1,x+1,y-1,portal[randomness-1][nnx]);
create_part(-1,x,y-1,portal[randomness-1][nnx]);
create_part(-1,x,y+1,portal[randomness-1][nnx]);
create_part(-1,x-1,y+1,portal[randomness-1][nnx]);
create_part(-1,x-1,y,portal[randomness-1][nnx]);
create_part(-1,x-1,y-1,portal[randomness-1][nnx]);
portal[randomness-1][nnx] = 0;
portaltemp[randomness-1][nnx] = 0;
create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
portal[parts[i].tmp][randomness-1][nnx] = 0;
portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
break;
}
else if(portal[randomness-1][nnx])
else if(portal[parts[i].tmp][randomness-1][nnx])
{
create_part(-1,x+nx,y+ny,portal[randomness-1][nnx]);
parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[randomness-1][nnx];
portal[randomness-1][nnx] = 0;
portaltemp[randomness-1][nnx] = 0;
create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
portal[parts[i].tmp][randomness-1][nnx] = 0;
portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
break;
}
}
@@ -3271,7 +3440,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r)
continue;
rt = parts[r>>8].type;
if((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL)
if((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
{
t = parts[i].life++;
if(parts[i].life==3)
@@ -3397,6 +3566,11 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = 10;
}
}
else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
{
parts[r>>8].type = parts[r>>8].ctype;
parts[r>>8].life = 9;
}
}
}
if(t==PT_SWCH)
@@ -3419,7 +3593,7 @@ void update_particles_i(pixel *vid, int start, int inc)
rt = parts[r>>8].type;
if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) &&
!(t==PT_PHOT && rt==PT_INSL) &&
(t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_CRAC && parts[r>>8].life>0) &&
(t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_SPNG && parts[r>>8].life>0) &&
ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000))
{
parts[r>>8].type = PT_FIRE;
@@ -3618,7 +3792,6 @@ killed:
//Death
if(parts[i].life<1 || death == 1 || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
{
death = 0;
for(r=-2; r<=1; r++)
{
create_part(-1, x+r, y-2, player[2]);
@@ -3997,6 +4170,414 @@ killed:
isplayer = 1;
}
if(t==PT_STKM2)
{
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
//Tempirature handling
if(parts[i].temp<243)
parts[i].life -= 1;
if((parts[i].temp<309.6f) && (parts[i].temp>=243))
parts[i].temp += 1;
//Death
if(parts[i].life<1 || death2 == 1 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != 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, player2[2]);
create_part(-1, x+r+1, y+2, player2[2]);
create_part(-1, x-2, y+r+1, player2[2]);
create_part(-1, x+2, y+r, player2[2]);
}
kill_part(i); //Kill him
goto killed;
}
parts[i].vy += -0.7*dt; //Head up!
//Verlet integration
pp = 2*player2[3]-player2[5]+player2[19]*dt*dt;;
player2[5] = player2[3];
player2[3] = pp;
pp = 2*player2[4]-player2[6]+player2[20]*dt*dt;;
player2[6] = player2[4];
player2[4] = pp;
pp = 2*player2[7]-player2[9]+player2[21]*dt*dt;;
player2[9] = player2[7];
player2[7] = pp;
pp = 2*player2[8]-player2[10]+(player2[22]+1)*dt*dt;;
player2[10] = player2[8];
player2[8] = pp;
pp = 2*player2[11]-player2[13]+player2[23]*dt*dt;;
player2[13] = player2[11];
player2[11] = pp;
pp = 2*player2[12]-player2[14]+player2[24]*dt*dt;;
player2[14] = player2[12];
player2[12] = pp;
pp = 2*player2[15]-player2[17]+player2[25]*dt*dt;;
player2[17] = player2[15];
player2[15] = pp;
pp = 2*player2[16]-player2[18]+(player2[26]+1)*dt*dt;;
player2[18] = player2[16];
player2[16] = pp;
//Setting acceleration to 0
player2[19] = 0;
player2[20] = 0;
player2[21] = 0;
player2[22] = 0;
player2[23] = 0;
player2[24] = 0;
player2[25] = 0;
player2[26] = 0;
//Go left
if (((int)(player2[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
{
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
{
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
{
player2[21] = -3;
player2[22] = -2;
player2[19] = -2;
}
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
{
player2[25] = -3;
player2[26] = -2;
player2[23] = -2;
}
}
else
{
if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) //It should move another way in liquids
{
player2[21] = -1;
player2[22] = -1;
player2[19] = -1;
}
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
{
player2[25] = -1;
player2[26] = -1;
player2[23] = -1;
}
}
}
//Go right
if (((int)(player2[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
{
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
{
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
{
player2[21] = 3;
player2[22] = -2;
player2[19] = 2;
}
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
{
player2[25] = 3;
player2[26] = -2;
player2[23] = 2;
}
}
else
{
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
{
player2[21] = 1;
player2[22] = -1;
player2[19] = 1;
}
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
{
player2[25] = 1;
player2[26] = -1;
player2[23] = 1;
}
}
}
//Jump
if (((int)(player2[0])&0x04) == 0x04 && (pstates[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS))
{
if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])])
{
parts[i].vy = -5;
player2[22] -= 1;
player2[26] -= 1;
}
}
//Charge detector wall if foot inside
if(bmap[(int)(player2[8]+0.5)/CELL][(int)(player2[7]+0.5)/CELL]==WL_DETECT)
set_emap((int)player2[7]/CELL, (int)player2[8]/CELL);
if(bmap[(int)(player2[16]+0.5)/CELL][(int)(player2[15]+0.5)/CELL]==WL_DETECT)
set_emap((int)(player2[15]+0.5)/CELL, (int)(player2[16]+0.5)/CELL);
//Searching for particles near head
for(nx = -2; nx <= 2; nx++)
for(ny = 0; ny>=-2; ny--)
{
if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
continue;
if(ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT)
{
player2[2] = pmap[ny+y][nx+x]&0xFF; //Current element
}
if((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
{
if(parts[i].life<=95)
parts[i].life += 5;
else
parts[i].life = 100;
kill_part(pmap[ny+y][nx+x]>>8);
}
if((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
{
parts[i].life -= (102-parts[i].life)/2;
kill_part(pmap[ny+y][nx+x]>>8);
}
if(bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
player2[2] = SPC_AIR;
}
//Head position
nx = x + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01);
ny = y - 3*(player2[1] == 0);
//Spawn
if(((int)(player2[0])&0x08) == 0x08)
{
ny -= 2*(rand()%2)+1;
r = pmap[ny][nx];
if(!((r>>8)>=NPART))
{
if(pstates[r&0xFF].state == ST_SOLID)
{
create_part(-1, nx, ny, PT_SPRK);
}
else
{
if(player2[2] == SPC_AIR)
create_parts(nx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
else
create_part(-1, nx, ny, player2[2]);
r = pmap[ny][nx];
if( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
if(((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT)
{
int random = abs(rand()%3-1)*3;
if (random==0)
{
parts[r>>8].life = 0;
parts[r>>8].type = PT_NONE;
}
else
{
parts[r>>8].vy = 0;
parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random;
}
}
}
}
}
//Simulation of joints
d = 25/(pow((player2[3]-player2[7]), 2) + pow((player2[4]-player2[8]), 2)+25) - 0.5; //Fast distance
player2[7] -= (player2[3]-player2[7])*d;
player2[8] -= (player2[4]-player2[8])*d;
player2[3] += (player2[3]-player2[7])*d;
player2[4] += (player2[4]-player2[8])*d;
d = 25/(pow((player2[11]-player2[15]), 2) + pow((player2[12]-player2[16]), 2)+25) - 0.5;
player2[15] -= (player2[11]-player2[15])*d;
player2[16] -= (player2[12]-player2[16])*d;
player2[11] += (player2[11]-player2[15])*d;
player2[12] += (player2[12]-player2[16])*d;
d = 36/(pow((player2[3]-parts[i].x), 2) + pow((player2[4]-parts[i].y), 2)+36) - 0.5;
parts[i].vx -= (player2[3]-parts[i].x)*d;
parts[i].vy -= (player2[4]-parts[i].y)*d;
player2[3] += (player2[3]-parts[i].x)*d;
player2[4] += (player2[4]-parts[i].y)*d;
d = 36/(pow((player2[11]-parts[i].x), 2) + pow((player2[12]-parts[i].y), 2)+36) - 0.5;
parts[i].vx -= (player2[11]-parts[i].x)*d;
parts[i].vy -= (player2[12]-parts[i].y)*d;
player2[11] += (player2[11]-parts[i].x)*d;
player2[12] += (player2[12]-parts[i].y)*d;
//Side collisions checking
for(nx = -3; nx <= 3; nx++)
{
r = pmap[(int)(player2[16]-2)][(int)(player2[15]+nx)];
if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
player2[15] -= nx;
r = pmap[(int)(player2[8]-2)][(int)(player2[7]+nx)];
if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
player2[7] -= nx;
}
//Collision checks
for(ny = -2-(int)parts[i].vy; ny<=0; ny++)
{
r = pmap[(int)(player2[8]+ny)][(int)(player2[7]+0.5)]; //This is to make coding more pleasant :-)
//For left leg
if (r && (r&0xFF)!=PT_STKM2)
{
if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks
{
if(parts[i].y<(player2[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(pstates[r&0xFF].state != ST_GAS)
{
player2[8] += ny-1;
parts[i].vy -= 0.5*parts[i].vy*dt;
}
}
player2[9] = player2[7];
}
r = pmap[(int)(player2[16]+ny)][(int)(player2[15]+0.5)];
//For right leg
if (r && (r&0xFF)!=PT_STKM2)
{
if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)
{
if(parts[i].y<(player2[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(pstates[r&0xFF].state != ST_GAS)
{
player2[16] += ny-1;
parts[i].vy -= 0.5*parts[i].vy*dt;
}
}
player2[17] = player2[15];
}
//If it falls too fast
if (parts[i].vy>=30)
{
parts[i].y -= (10+ny)*dt;
parts[i].vy = -10*dt;
}
}
//Keeping legs distance
if (pow((player2[7] - player2[15]), 2)<16 && pow((player2[8]-player2[16]), 2)<1)
{
player2[21] -= 0.2;
player2[25] += 0.2;
}
if (pow((player2[3] - player2[11]), 2)<16 && pow((player2[4]-player2[12]), 2)<1)
{
player2[19] -= 0.2;
player2[23] += 0.2;
}
//If legs touch something
r = pmap[(int)(player2[8]+0.5)][(int)(player2[7]+0.5)];
if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
{
parts[i].life -= (int)(rand()/1000)+38;
}
if (r>0 && (r>>8)<NPART) //If hot or cold
{
if(parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
{
parts[i].life -= 2;
player2[26] -= 1;
}
}
if ((r&0xFF)==PT_ACID) //If on acid
parts[i].life -= 5;
if ((r&0xFF)==PT_PLUT) //If on plut
parts[i].life -= 1;
r = pmap[(int)(player2[16]+0.5)][(int)(player2[15]+0.5)];
if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
{
parts[i].life -= (int)(rand()/1000)+38;
}
if(r>0 && (r>>8)<NPART) //If hot or cold
{
if(parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
{
parts[i].life -= 2;
player2[22] -= 1;
}
}
if ((r&0xFF)==PT_ACID) //If on acid
parts[i].life -= 5;
if ((r&0xFF)==PT_PLUT) //If on plut
parts[i].life -= 1;
isplayer2 = 1;
}
if(t==PT_SPAWN)
{
if(death==1)
{
playerspawn = create_part(-1,x,y,PT_STKM);
isplayer = 1;
}
death = 0;
}
if(t==PT_SPAWN2)
{
if(death2==1)
{
player2spawn = create_part(-1,x,y,PT_STKM2);
isplayer2 = 1;
}
death2 = 0;
}
if(t==PT_CLNE)
{
if(!parts[i].ctype)
@@ -4010,6 +4591,7 @@ killed:
(pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4031,6 +4613,7 @@ killed:
(pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
}
@@ -4054,6 +4637,7 @@ killed:
(pmap[y+ny][x+nx]&0xFF)!=PT_NSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_PSCN &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
if(parts[i].ctype && parts[i].life==10) {
@@ -4371,6 +4955,7 @@ void update_particles(pixel *vid)
#endif
isplayer = 0; //Needed for player spawning
isplayer2 = 0;
memset(pmap, 0, sizeof(pmap));
r = rand()%2;
NUM_PARTS = 0;
@@ -4895,6 +5480,72 @@ void update_particles(pixel *vid)
}
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
int cx = 0;
int cy = 0;
unsigned tpmap[area_h][area_w];
unsigned rtpmap[area_w][area_h];
unsigned char tbmap[area_h/CELL][area_w/CELL];
unsigned char rtbmap[area_w/CELL][area_h/CELL];
for(cy=0; cy<area_h; cy++)
{
for(cx=0; cx<area_w; cx++)//save walls to temp
{
if(area_x + cx<XRES&&area_y + cy<YRES)
{
if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
else
tbmap[cy/CELL][cx/CELL] = 0;
}
}
}
for(cy=0; cy<area_h; cy++)
{
for(cx=0; cx<area_w; cx++)//save particles to temp
{
if((area_x + cx<XRES&&area_y + cy<YRES))
{
tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
}
else
tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
}
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//rotate temp arrays
{
if(invert)
{
rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
}
else
{
rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
}
}
}
for(cy=0; cy<area_w; cy++)
{
for(cx=0; cx<area_h; cx++)//move particles and walls
{
if(area_x + cx<XRES&&area_y + cy<YRES)
{
if((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
{
parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
}
bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
}
}
}
}
void clear_area(int area_x, int area_y, int area_w, int area_h)
{
int cx = 0;
@@ -5129,7 +5780,10 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
create_part(-1, x+i, y+j, c);
if(!REPLACE_MODE)
create_part(-2, x+i, y+j, c);
else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
create_part(-2, x+i, y+j, c);
return 1;
}
@@ -5156,7 +5810,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
delete_part(x+i, y+j);
if(c!=0)
create_part(-1, x+i, y+j, c);
create_part(-2, x+i, y+j, c);
}
}
return 1;
@@ -5165,7 +5819,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for(j=-ry; j<=ry; j++)
for(i=-rx; i<=rx; i++)
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
if(create_part(-1, x+i, y+j, c)==-1)
if(create_part(-2, x+i, y+j, c)==-1)
f = 1;
return !f;
}