From 417b740d468b8ae3d35872d4d02fd34999da4903 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 22 Feb 2011 17:51:51 +0000 Subject: [PATCH 01/11] Make the help screen a bit cleaner --- src/main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 3fa2828f9..b8eadc02d 100644 --- a/src/main.c +++ b/src/main.c @@ -118,7 +118,7 @@ void play_sound(char *file) } static const char *it_msg = - "\brThe Powder Toy - http://powdertoy.co.uk/\n" + "\brThe Powder Toy - http://powdertoy.co.uk, irc.freenode.net #powder\n" "\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\n" "\n" "\bgControl+C/V/X are Copy, Paste and cut respectively.\n" @@ -138,12 +138,8 @@ static const char *it_msg = "The spacebar can be used to pause physics.\n" "'P' will take a screenshot and save it into the current directory.\n" "\n" - "\bgCopyright (c) 2008-10 Stanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg)\n" - "\bgCopyright (c) 2010 Simon Robertshaw (\brhttp://powdertoy.co.uk\bg, \bbirc.freenode.net #powder\bg)\n" - "\bgCopyright (c) 2010 Skresanov Savely (Stickman)\n" - "\bgCopyright (c) 2010 cracker64\n" - "\bgCopyright (c) 2010 Bryan Hoyle (New elements)\n" - "\bgCopyright (c) 2010 Nathan Cousins (New elements, small engine mods.)\n" + "\bgCopyright (c) 2008-11 Stanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg)\n" + "\bgCopyright (c) 2010-11 Simon Robertshaw, Skresanov Savely, cracker64, Bryan Hoyle, Nathan Cousins, jacksonmj\n" "\n" "\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html" ; From 9b3c25227a298d946ce357868c434ce21f8ef14c Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 23 Feb 2011 09:55:50 +0800 Subject: [PATCH 02/11] Reduce GoL lag --- src/powder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index 78562b8fb..ba2cd175b 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1353,10 +1353,12 @@ void update_particles_i(pixel *vid, int start, int inc) if (r && parts[r>>8].tmp<=0) parts[r>>8].type = PT_NONE;//using kill_part makes it not work } + for( z = 0;z<=NGOL;z++) + gol2[nx][ny][z] = 0;//this improves performance A LOT compared to the memset, i was getting ~23 more fps with this. } if (createdsomething) GENERATION ++; - memset(gol2, 0, sizeof(gol2)); + //memset(gol2, 0, sizeof(gol2)); } if (ISWIRE==1) { From 0028dc843176d727497e17d473cb529421b4eaff Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 23 Feb 2011 17:15:25 +0000 Subject: [PATCH 03/11] Increase debug coords string buffer to prevent crashes --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index b8eadc02d..bb99db692 100644 --- a/src/main.c +++ b/src/main.c @@ -1179,7 +1179,7 @@ int main(int argc, char *argv[]) #endif char uitext[512] = ""; char heattext[128] = ""; - char coordtext[13] = ""; + char coordtext[128] = ""; int currentTime = 0; int FPS = 0; int pastFPS = 0; From fa76c4b45cd8de61508c62e8d276aee5a6083769 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 23 Feb 2011 17:16:13 +0000 Subject: [PATCH 04/11] Increase minor version --- includes/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/defines.h b/includes/defines.h index 01c281216..f3abed394 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,7 +8,7 @@ #endif #define SAVE_VERSION 46 -#define MINOR_VERSION 3 +#define MINOR_VERSION 4 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. //#define BETA From 5d4d815ad3e6510210c8b6646d972f317cb44caa Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 23 Feb 2011 20:35:02 +0000 Subject: [PATCH 05/11] Fancier glow, now affected by Velocity, Pressure and Heat --- includes/powder.h | 2 +- src/elements/glow.c | 4 ++++ src/graphics.c | 38 +++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 9964abadd..a8bd6bfad 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -435,7 +435,7 @@ static const part_type ptypes[PT_NUM] = {"YEST", PIXPACK(0xEEE0C0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 15, 0, 0, 30, 1, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Yeast, grows when warm (~37C).", ST_SOLID, TYPE_PART, &update_YEST}, {"DYST", PIXPACK(0xBBB0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 20, 0, 0, 30, 0, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Dead Yeast.", ST_SOLID, TYPE_PART, NULL}, {"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremely high temperature.", ST_SOLID, TYPE_PART, &update_THRM}, - {"GLOW", PIXPACK(0x445544), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW}, + {"GLOW", PIXPACK(0x445464), 0.3f, 0.02f * CFDS, 0.98f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW}, {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW, NULL}, {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL}, {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", ST_SOLID, TYPE_PART, &update_FIRW}, diff --git a/src/elements/glow.c b/src/elements/glow.c index 621e5b1c7..0993e6166 100644 --- a/src/elements/glow.c +++ b/src/elements/glow.c @@ -16,6 +16,10 @@ int update_GLOW(UPDATE_FUNC_ARGS) { parts[r>>8].life = 10; } } + parts[i].life = pv[y/CELL][x/CELL]*16; + + parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); + //printf("%f %f\n", parts[i].vx, parts[i].vy); if (parts[i].type==PT_NONE) { kill_part(i); return 1; diff --git a/src/graphics.c b/src/graphics.c index ea8d0d545..4b29dc700 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2370,15 +2370,15 @@ void draw_parts(pixel *vid) } else if (t==PT_GLOW) { - fg = 0; - fb = 0; - fr = 0; - if (pv[ny/CELL][nx/CELL]>0) { - fg = 6 * pv[ny/CELL][nx/CELL]; - fb = 4 * pv[ny/CELL][nx/CELL]; - fr = 2 * pv[ny/CELL][nx/CELL]; - } - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); + fr = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f; + fg = restrict_flt(parts[i].life, 0, 128)/50.0f; + fb = restrict_flt(parts[i].tmp, 0, 128)/50.0f; + + cr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255); + cg = restrict_flt(64.0f+parts[i].life, 0, 255); + cb = restrict_flt(64.0f+parts[i].tmp, 0, 255); + + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr, cg, cb); if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { x = nx/CELL; @@ -2394,19 +2394,15 @@ void draw_parts(pixel *vid) fire_r[y][x] = fr; } if (cmode == CM_BLOB) { - uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255); - uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255); - uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255); + blendpixel(vid, nx+1, ny, cr, cg, cb, 223); + blendpixel(vid, nx-1, ny, cr, cg, cb, 223); + blendpixel(vid, nx, ny+1, cr, cg, cb, 223); + blendpixel(vid, nx, ny-1, cr, cg, cb, 223); - blendpixel(vid, nx+1, ny, R, G, B, 223); - blendpixel(vid, nx-1, ny, R, G, B, 223); - blendpixel(vid, nx, ny+1, R, G, B, 223); - blendpixel(vid, nx, ny-1, R, G, B, 223); - - blendpixel(vid, nx+1, ny-1, R, G, B, 112); - blendpixel(vid, nx-1, ny-1, R, G, B, 112); - blendpixel(vid, nx+1, ny+1, R, G, B, 112); - blendpixel(vid, nx-1, ny+1, R, G, B, 112); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); } } else if (t==PT_LCRY) From 1b9b1752a77ec0bd9c9d9b02a6a0103f1e7f8c21 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 23 Feb 2011 20:54:11 +0000 Subject: [PATCH 06/11] Switch life to ctype for, photons apparently use the GLOW ctype for something --- src/elements/glow.c | 2 +- src/graphics.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/elements/glow.c b/src/elements/glow.c index 0993e6166..d69223305 100644 --- a/src/elements/glow.c +++ b/src/elements/glow.c @@ -16,7 +16,7 @@ int update_GLOW(UPDATE_FUNC_ARGS) { parts[r>>8].life = 10; } } - parts[i].life = pv[y/CELL][x/CELL]*16; + parts[i].ctype = pv[y/CELL][x/CELL]*16; parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); //printf("%f %f\n", parts[i].vx, parts[i].vy); diff --git a/src/graphics.c b/src/graphics.c index 4b29dc700..cea2ba72a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2371,11 +2371,11 @@ void draw_parts(pixel *vid) else if (t==PT_GLOW) { fr = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f; - fg = restrict_flt(parts[i].life, 0, 128)/50.0f; + fg = restrict_flt(parts[i].ctype, 0, 128)/50.0f; fb = restrict_flt(parts[i].tmp, 0, 128)/50.0f; cr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255); - cg = restrict_flt(64.0f+parts[i].life, 0, 255); + cg = restrict_flt(64.0f+parts[i].ctype, 0, 255); cb = restrict_flt(64.0f+parts[i].tmp, 0, 255); vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr, cg, cb); From a64c202834e34760016932d401d0fb71b17ba56d Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 24 Feb 2011 05:15:54 +0800 Subject: [PATCH 07/11] Fix lava freezing point --- src/powder.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/powder.c b/src/powder.c index ba2cd175b..11215d2d0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1568,10 +1568,12 @@ void update_particles_i(pixel *vid, int start, int inc) } else if (t==PT_LAVA) { if (parts[i].ctype && parts[i].ctype=ptransitions[parts[i].ctype].thv) s = 0; - else if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0; + if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0; + else if (ptransitions[parts[i].ctype].tht==PT_LAVA) { + if (pt>=ptransitions[parts[i].ctype].thv) s = 0; + } else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype - else { + if (s) { t = parts[i].ctype; parts[i].ctype = PT_NONE; if (t==PT_THRM) { From 3011367eb09249d94462c769da2e708e8a9aa930 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 24 Feb 2011 08:57:13 +0800 Subject: [PATCH 08/11] Fix particles displaced by liquids moving to overlapping positions --- src/powder.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/powder.c b/src/powder.c index 11215d2d0..98fedb275 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1990,7 +1990,9 @@ killed: if (try_move(i, x, y, j, clear_y)) { parts[i].x = clear_xf+(j-clear_x); + parts[i].y = clear_yf; nx = j; + ny = clear_y; s = 1; break; } @@ -2002,11 +2004,11 @@ killed: else r = -1; if (s) - for (j=clear_y+r; j>=0 && j=clear_y-rt && j=0 && j=ny-rt && j Date: Thu, 24 Feb 2011 02:33:36 +0800 Subject: [PATCH 09/11] Fix GoL to not set gol2 on other things --- src/powder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/powder.c b/src/powder.c index 98fedb275..b2751c5a3 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1320,8 +1320,12 @@ void update_particles_i(pixel *vid, int start, int inc) for ( nnx=-1; nnx<2; nnx++) for ( nny=-1; nny<2; nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check { - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; + rt = pmap[((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL]; + if (!rt || ptypes[rt&0xFF].properties&PROP_LIFE) + { + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; + } } } else { parts[r>>8].tmp --; From fd6f6c5406c3af9bcb679e5381800b8708ba3d8a Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 24 Feb 2011 17:11:05 +0000 Subject: [PATCH 10/11] WIND from cracker! --- includes/powder.h | 7 +++++-- src/main.c | 17 +++++++++++++++-- src/powder.c | 4 ++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index a8bd6bfad..581c8da4a 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -196,7 +196,8 @@ #define PT_STAR 144 #define PT_FROG 145 #define PT_BRAN 146 -#define PT_NUM 147 +#define PT_WIND 147 +#define PT_NUM 148 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -437,7 +438,7 @@ static const part_type ptypes[PT_NUM] = {"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremely high temperature.", ST_SOLID, TYPE_PART, &update_THRM}, {"GLOW", PIXPACK(0x445464), 0.3f, 0.02f * CFDS, 0.98f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW}, {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW, NULL}, - {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL}, + {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL}, {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", ST_SOLID, TYPE_PART, &update_FIRW}, {"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", ST_SOLID, TYPE_SOLID, &update_FUSE}, {"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", ST_SOLID, TYPE_PART, &update_FSEP}, @@ -516,6 +517,7 @@ static const part_type ptypes[PT_NUM] = {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"WIND", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, 0.0f, 40, "Drag tool", ST_NONE, ST_NONE, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; @@ -678,6 +680,7 @@ static part_transition ptransitions[PT_NUM] = /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WIND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, }; #undef IPL #undef IPH diff --git a/src/main.c b/src/main.c index bb99db692..6de200af7 100644 --- a/src/main.c +++ b/src/main.c @@ -2432,7 +2432,20 @@ int main(int argc, char *argv[]) } else { - create_line(lx, ly, x, y, bsx, bsy, c); + if (c == PT_WIND) + { + for (j=-bsy; j<=bsy; j++) + for (i=-bsx; i<=bsx; i++) + if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)) + { + vx[(y+j)/CELL][(x+i)/CELL] += (x-lx)*0.01f; + vy[(y+j)/CELL][(x+i)/CELL] += (y-ly)*0.01f; + } + } + else + { + create_line(lx, ly, x, y, bsx, bsy, c); + } lx = x; ly = y; } @@ -2457,7 +2470,7 @@ int main(int argc, char *argv[]) { if (sdl_mod & (KMOD_CAPS)) c = 0; - if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE) + if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&c!=PT_WIND&&!REPLACE_MODE) flood_parts(x, y, c, -1, -1); if (c==SPC_HEAT || c==SPC_COOL) create_parts(x, y, bsx, bsy, c); diff --git a/src/powder.c b/src/powder.c index b2751c5a3..55c12337e 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2864,6 +2864,10 @@ int create_parts(int x, int y, int rx, int ry, int c) b = WL_FANHELPER; dw = 1; } + if (c == PT_WIND) + { + return 1; + } if (dw==1) { rx = rx/CELL; From 669a672b3d083af22c6aeb37a636903ce30bcf6c Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 24 Feb 2011 18:04:08 +0000 Subject: [PATCH 11/11] Pretty transparent console --- src/interface.c | 41 +++++++++++++++++++++++------------------ src/main.c | 40 ++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/interface.c b/src/interface.c index a762b39d7..9b1b495cd 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3841,10 +3841,11 @@ typedef struct command_history command_history; command_history *last_command = NULL; char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands int mx,my,b,cc,ci = -1; + pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); command_history *currentcommand; ui_edit ed; ed.x = 15; - ed.y = 210; + ed.y = 207; ed.w = XRES; ed.nx = 1; ed.def = ""; @@ -3854,6 +3855,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show ed.multiline = 0; ed.cursor = 0; //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); + fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + cc = 0; + while(cc < 80){ + fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2)); + cc++; + } while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my); @@ -3861,21 +3869,12 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show my /= sdl_scale; ed.focus = 1; - clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? - draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); - drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill, sound\n" - "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" - "You can also use 'all' instead of a particle number to do it to everything.\n" - "You can now use particle names (ex. set type all deut)\n" - "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" - "To load a save use load saveID (ex. load 1337)\n" - "Create particles with 'create deut x,y' where x and y are the coords\n" - "Run scripts from file 'file filename'\n" - "You can delete/kill a particle with 'kill x,y'" - "Play a sound with (sound blah.wav)" - ,255, 187, 187, 255); - + memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); + draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE); + drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64)\n" + "Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command + ,255, 255, 255, 255); + cc = 0; currentcommand = last_command; while(cc < 10) @@ -3899,8 +3898,11 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } - if(error) - drawtext(vid_buf, 15, 190, error,255, 187, 187, 255); + if(error && ed.str[0]=='\0') + drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200); + + drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240); + ui_edit_draw(vid_buf, &ed); ui_edit_process(mx, my, b, &ed); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); @@ -3911,11 +3913,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show currentcommand->prev_command = last_command; currentcommand->command = mystrdup(ed.str); last_command = currentcommand; + free(old_buf); return currentcommand->command; } if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE) { console_mode = 0; + free(old_buf); return NULL; } if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) @@ -3951,6 +3955,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } console_mode = 0; + free(old_buf); return NULL; } diff --git a/src/main.c b/src/main.c index 6de200af7..165742512 100644 --- a/src/main.c +++ b/src/main.c @@ -1677,7 +1677,7 @@ int main(int argc, char *argv[]) if (sdl_key==SDLK_BACKQUOTE) { console_mode = !console_mode; - hud_enable = !console_mode; + //hud_enable = !console_mode; } if (sdl_key=='g') { @@ -1906,23 +1906,6 @@ int main(int argc, char *argv[]) }*/ } } - if(console_mode) - { - char *console; - //char error[255] = "error!"; - sys_pause = 1; - console = console_ui(vid_buf,console_error); - console = mystrdup(console); - strcpy(console_error,""); - if(process_command(vid_buf,console,&console_error)==-1) - { - free(console); - break; - } - free(console); - if(!console_mode) - hud_enable = 1; - } bq = b; b = SDL_GetMouseState(&x, &y); @@ -1982,6 +1965,7 @@ int main(int argc, char *argv[]) } } } + mx = x; my = y; if (update_flag) @@ -2743,7 +2727,27 @@ int main(int argc, char *argv[]) } fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140); drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200); + } + + if(console_mode) + { + char *console; + //char error[255] = "error!"; + sys_pause = 1; + console = console_ui(vid_buf,console_error); + console = mystrdup(console); + strcpy(console_error,""); + if(process_command(vid_buf,console,&console_error)==-1) + { + free(console); + break; + } + free(console); + if(!console_mode) + hud_enable = 1; + } + sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE); //Setting an element for the stick man