summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-02-26 19:32:51 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2011-02-26 19:32:51 (GMT)
commitded7bdf30d87601e125ce06fee0a6614cd424f73 (patch)
tree9b9004facb67d6276e9a2c8f6c79449834c5a229 /src
parenta972644c4ffda6774ecea2798ff6d76f09d8f04e (diff)
parent669a672b3d083af22c6aeb37a636903ce30bcf6c (diff)
downloadpowder-ded7bdf30d87601e125ce06fee0a6614cd424f73.zip
powder-ded7bdf30d87601e125ce06fee0a6614cd424f73.tar.gz
Merge branch 'upstream' into dev
Conflicts: src/main.c
Diffstat (limited to 'src')
-rw-r--r--src/elements/glow.c4
-rw-r--r--src/graphics.c40
-rw-r--r--src/interface.c41
-rw-r--r--src/main.c69
-rw-r--r--src/powder.c16
5 files changed, 99 insertions, 71 deletions
diff --git a/src/elements/glow.c b/src/elements/glow.c
index 621e5b1..d692233 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].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);
if (parts[i].type==PT_NONE) {
kill_part(i);
return 1;
diff --git a/src/graphics.c b/src/graphics.c
index ea8d0d5..cea2ba7 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].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].ctype, 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, 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, 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-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)
diff --git a/src/interface.c b/src/interface.c
index a762b39..9b1b495 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 3dbebd3..82c9429 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"
;
@@ -1193,7 +1189,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;
@@ -1691,7 +1687,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')
{
@@ -1920,23 +1916,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);
@@ -1996,6 +1975,7 @@ int main(int argc, char *argv[])
}
}
}
+
mx = x;
my = y;
if (update_flag)
@@ -2425,7 +2405,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;
}
@@ -2450,7 +2443,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);
@@ -2723,7 +2716,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
diff --git a/src/powder.c b/src/powder.c
index bb77385..dbbfe0c 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 --;
@@ -1353,10 +1357,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)
{
@@ -2858,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;