diff --git a/includes/graphics.h b/includes/graphics.h index d028e9bfa..6d9a27311 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -114,6 +114,8 @@ void xor_rect(pixel *vid, int x, int y, int w, int h); void draw_parts(pixel *vid); +void draw_walls(pixel *vid); + void draw_decorations(pixel *vid_buf,pixel *decorations); void draw_wavelengths(pixel *vid, int x, int y, int h, int wl); diff --git a/includes/interface.h b/includes/interface.h index 9dc07f886..cadffd930 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -12,36 +12,6 @@ struct menu_section }; typedef struct menu_section menu_section; -struct menu_wall -{ - pixel colour; - const char *descs; -}; -typedef struct menu_wall menu_wall; - -static menu_wall mwalls[] = -{ - {PIXPACK(0xC0C0C0), "Wall. Indestructible. Blocks everything. Conductive."}, - {PIXPACK(0x808080), "E-Wall. Becomes transparent when electricity is connected."}, - {PIXPACK(0xFF8080), "Detector. Generates electricity when a particle is inside."}, - {PIXPACK(0x808080), "Streamline. Set start point of a streamline."}, - {PIXPACK(0x808080), "Sign. Click on a sign to edit it or anywhere else to place a new one."}, - {PIXPACK(0x8080FF), "Fan. Accelerates air. Use line tool to set direction and strength."}, - {PIXPACK(0xC0C0C0), "Wall. Blocks most particles but lets liquids through. Conductive."}, - {PIXPACK(0x808080), "Wall. Absorbs particles but lets air currents through."}, - {PIXPACK(0x808080), "Erases walls."}, - {PIXPACK(0x808080), "Wall. Indestructible. Blocks everything."}, - {PIXPACK(0x3C3C3C), "Wall. Indestructible. Blocks particles, allows air"}, - {PIXPACK(0x575757), "Wall. Indestructible. Blocks liquids and gasses, allows solids"}, - {PIXPACK(0xFFFF22), "Conductor, allows particles, conducts electricity"}, - {PIXPACK(0x242424), "E-Hole, absorbs particles, release them when powered"}, - {PIXPACK(0xFFFFFF), "Air, creates airflow and pressure"}, - {PIXPACK(0xFFBB00), "Heats the targetted element."}, - {PIXPACK(0x00BBFF), "Cools the targetted element."}, - {PIXPACK(0x303030), "Vacuum, reduces air pressure."}, - {PIXPACK(0x579777), "Wall. Indestructible. Blocks liquids and solids, allows gasses"}, -}; - #define SC_WALL 0 #define SC_SPECIAL 8 #define SC_POWDERS 5 diff --git a/includes/powder.h b/includes/powder.h index 5d71e8f19..66c7f8a07 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -782,6 +782,39 @@ static int lolzrule[9][9] = {0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0}, }; + +struct wall_type +{ + pixel colour; + pixel eglow; // if emap set, add this to fire glow + int drawstyle; + const char *descs; +}; +typedef struct wall_type wall_type; + +static wall_type wtypes[] = +{ + {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, "Wall. Indestructible. Blocks everything. Conductive."}, + {PIXPACK(0x808080), PIXPACK(0x808080), 0, "E-Wall. Becomes transparent when electricity is connected."}, + {PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, "Detector. Generates electricity when a particle is inside."}, + {PIXPACK(0x808080), PIXPACK(0x000000), 0, "Streamline. Set start point of a streamline."}, + {PIXPACK(0x808080), PIXPACK(0x000000), 0, "Sign. Click on a sign to edit it or anywhere else to place a new one."}, + {PIXPACK(0x8080FF), PIXPACK(0x000000), 1, "Fan. Accelerates air. Use line tool to set direction and strength."}, + {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, "Wall. Blocks most particles but lets liquids through. Conductive."}, + {PIXPACK(0x808080), PIXPACK(0x000000), 1, "Wall. Absorbs particles but lets air currents through."}, + {PIXPACK(0x808080), PIXPACK(0x000000), 1, "Erases walls."}, + {PIXPACK(0x808080), PIXPACK(0x000000), 3, "Wall. Indestructible. Blocks everything."}, + {PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks particles, allows air"}, + {PIXPACK(0x575757), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and gasses, allows solids"}, + {PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, "Conductor, allows particles, conducts electricity"}, + {PIXPACK(0x242424), PIXPACK(0x101010), 0, "E-Hole, absorbs particles, release them when powered"}, + {PIXPACK(0xFFFFFF), PIXPACK(0x000000), -1, "Air, creates airflow and pressure"}, + {PIXPACK(0xFFBB00), PIXPACK(0x000000), -1, "Heats the targetted element."}, + {PIXPACK(0x00BBFF), PIXPACK(0x000000), -1, "Cools the targetted element."}, + {PIXPACK(0x303030), PIXPACK(0x000000), -1, "Vacuum, reduces air pressure."}, + {PIXPACK(0x579777), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and solids, allows gasses"}, +}; + #define CHANNELS ((int)(MAX_TEMP-73.15f)/100+2) particle portalp[CHANNELS][8][80]; const particle emptyparticle; diff --git a/src/graphics.c b/src/graphics.c index 8a52e16a5..a3fde2c49 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3063,6 +3063,174 @@ void draw_parts(pixel *vid) #endif } +void draw_walls(pixel *vid) +{ + int x, y, i, j, cr, cg, cb; + unsigned char wt; + pixel pc; + for (y=0; y>1)&1; i>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg = fire_g[y][x] + PIXG(pc); + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb = fire_b[y][x] + PIXB(pc); + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + + } + } +} + void draw_decorations(pixel *vid_buf,pixel *decorations) { int i,r,g,b; diff --git a/src/interface.c b/src/interface.c index a60e2aa34..fd4e7ff68 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1725,7 +1725,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq x = XRES-BARSIZE-18; y += 19; }*/ - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; + x -= draw_tool_xy(vid_buf, x, y, n, wtypes[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); @@ -1762,7 +1762,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq x = XRES-BARSIZE-18; y += 19; }*/ - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; + x -= draw_tool_xy(vid_buf, x, y, n, wtypes[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); @@ -1869,7 +1869,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq } else if (i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART)) { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255); + drawtext(vid_buf, XRES-textwidth((char *)wtypes[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)wtypes[h-UI_WALLSTART].descs, 255, 255, 255, 255); } else { @@ -4598,4 +4598,4 @@ void simulation_ui(pixel * vid_buf) if (!b) break; } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c index 3464d4636..ca968d2bd 100644 --- a/src/main.c +++ b/src/main.c @@ -1310,6 +1310,7 @@ int main(int argc, char *argv[]) for(i=0; i<30; i++){ memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + draw_walls(vid_buf); update_particles(vid_buf); draw_parts(vid_buf); render_fire(vid_buf); @@ -1616,8 +1617,10 @@ int main(int argc, char *argv[]) if (!sys_pause||framerender) //Only update if not paused memset(gravmap, 0, sizeof(gravmap)); //Clear the old gravmap + if(ngrav_enable) draw_grav(vid_buf); + draw_walls(vid_buf); update_particles(vid_buf); //update everything draw_parts(vid_buf); //draw particles diff --git a/src/powder.c b/src/powder.c index f31e1159b..2264f09f8 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2118,481 +2118,22 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but } } pfree=l; - if (cmode==CM_BLOB)//draw walls in BLOB mode differently, this should be moved elsewhere + for (y=0; y>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_FAN) - for (j=0; j>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_EWALL) - { - if (emap[y][x]) - { - cr = cg = cb = 128; - cr += fire_r[y][x]; - if (cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_ALLOWALLELEC) - { - for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_ALLOWGAS) - { - for (j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (emap[y][x] && (!sys_pause||framerender)) - emap[y][x] --; - } - } - } - else //draw walls in other modes, this should be elsewhere - { - for (y=0; y>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_FAN) - for (j=0; j>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_EWALL) - { - if (emap[y][x]) - { - cr = cg = cb = 128; - cr += fire_r[y][x]; - if (cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_ALLOWALLELEC) - { - for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (bmap[y][x]==WL_ALLOWAIR) - { - for (j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if (cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if (cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if (emap[y][x] && (!sys_pause||framerender)) - emap[y][x] --; - } + if (bmap[y][x]==WL_WALL || bmap[y][x]==WL_WALLELEC || (bmap[y][x]==WL_EWALL&&!emap[y][x])) + for (j=0; j