summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsavask <savask@yandex.ru>2011-08-29 16:47:22 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-26 14:31:55 (GMT)
commit00d604820d4900a422efd43dd3dd0a6f225e4adf (patch)
treec0c578eeffcfac21c440e9e00b09ce5ad1a88404 /src
parentf8d54e66dba5d8448d30f61f84883b4e7e6e1087 (diff)
downloadpowder-00d604820d4900a422efd43dd3dd0a6f225e4adf.zip
powder-00d604820d4900a422efd43dd3dd0a6f225e4adf.tar.gz
Added fighters.
Diffstat (limited to 'src')
-rw-r--r--src/elements/figh.c7
-rw-r--r--src/graphics.c1169
-rw-r--r--src/main.c10
-rw-r--r--src/powder.c64
4 files changed, 709 insertions, 541 deletions
diff --git a/src/elements/figh.c b/src/elements/figh.c
new file mode 100644
index 0000000..c67ebf9
--- /dev/null
+++ b/src/elements/figh.c
@@ -0,0 +1,7 @@
+#include <element.h>
+
+int update_FIGH(UPDATE_FUNC_ARGS)
+{
+ run_stickman(fighters[(unsigned char)parts[i].tmp], UPDATE_FUNC_SUBCALL_ARGS);
+ return 0;
+}
diff --git a/src/graphics.c b/src/graphics.c
index fd6c2b2..9e86386 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1017,25 +1017,103 @@ inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
if (!bn)
{
ba = *(rp++);
- bn = 8;
- }
- drawpixel(vid, x+i, y+j, r, g, b, ((ba&3)*a)/3);
- ba >>= 2;
- bn -= 2;
+ bn = 8;
}
- return x + w;
+ drawpixel(vid, x+i, y+j, r, g, b, ((ba&3)*a)/3);
+ ba >>= 2;
+ bn -= 2;
+ }
+return x + w;
}
int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a)
{
#ifdef OpenGL
#else
- int sx = x;
- for (; *s; s++)
+int sx = x;
+for (; *s; s++)
+{
+ if (*s == '\n')
+ {
+ x = sx;
+ y += FONT_H+2;
+ }
+ else if (*s == '\b')
+ {
+ switch (s[1])
+ {
+ case 'w':
+ r = g = b = 255;
+ break;
+ case 'g':
+ r = g = b = 192;
+ break;
+ case 'o':
+ r = 255;
+ g = 216;
+ b = 32;
+ break;
+ case 'r':
+ r = 255;
+ g = b = 0;
+ break;
+ case 'b':
+ r = g = 0;
+ b = 255;
+ break;
+ case 't':
+ b = 255;
+ g = 170;
+ r = 32;
+ break;
+ }
+ s++;
+ }
+ else
+ x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
+}
+#endif
+return x;
+}
+
+//Draw text with an outline
+int drawtext_outline(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a, int or, int og, int ob, int oa)
+{
+drawtext(vid, x-1, y-1, s, or, og, ob, oa);
+drawtext(vid, x+1, y+1, s, or, og, ob, oa);
+
+drawtext(vid, x-1, y+1, s, or, og, ob, oa);
+drawtext(vid, x+1, y-1, s, or, og, ob, oa);
+
+return drawtext(vid, x, y, s, r, g, b, a);
+}
+int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, int b, int a)
+{
+#ifdef OpenGL
+#else
+int sx = x;
+int rh = 12;
+int rw = 0;
+int cw = x;
+int wordlen;
+int charspace;
+while (*s)
+{
+ wordlen = strcspn(s," .,!?\n");
+ charspace = textwidthx((char *)s, w-(x-cw));
+ if (charspace<wordlen && wordlen && w-(x-cw)<w/3)
+ {
+ x = sx;
+ rw = 0;
+ y+=FONT_H+2;
+ rh+=FONT_H+2;
+ }
+ for (; *s && --wordlen>=-1; s++)
{
if (*s == '\n')
{
x = sx;
+ rw = 0;
y += FONT_H+2;
}
else if (*s == '\b')
@@ -1065,56 +1143,13 @@ int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a
r = g = 0;
b = 255;
break;
- case 't':
- b = 255;
- g = 170;
- r = 32;
- break;
}
s++;
}
else
- x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
- }
-#endif
- return x;
-}
-
-//Draw text with an outline
-int drawtext_outline(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a, int or, int og, int ob, int oa)
-{
- drawtext(vid, x-1, y-1, s, or, og, ob, oa);
- drawtext(vid, x+1, y+1, s, or, og, ob, oa);
-
- drawtext(vid, x-1, y+1, s, or, og, ob, oa);
- drawtext(vid, x+1, y-1, s, or, og, ob, oa);
-
- return drawtext(vid, x, y, s, r, g, b, a);
-}
-int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, int b, int a)
-{
-#ifdef OpenGL
-#else
- int sx = x;
- int rh = 12;
- int rw = 0;
- int cw = x;
- int wordlen;
- int charspace;
- while (*s)
- {
- wordlen = strcspn(s," .,!?\n");
- charspace = textwidthx((char *)s, w-(x-cw));
- if (charspace<wordlen && wordlen && w-(x-cw)<w/3)
- {
- x = sx;
- rw = 0;
- y+=FONT_H+2;
- rh+=FONT_H+2;
- }
- for (; *s && --wordlen>=-1; s++)
{
- if (*s == '\n')
+
+ if (x-cw>=w)
{
x = sx;
rw = 0;
@@ -1167,36 +1202,38 @@ int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, i
}
x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
}
+ x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
}
}
+}
- return rh;
- #endif
+return rh;
+#endif
}
//draws a rectange, (x,y) are the top left coords.
void drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a)
{
#ifdef OpenGL
- glBegin(GL_LINE_LOOP);
- glColor4ub(r, g, b, a);
- glVertex2i(x, y);
- glVertex2i(x+w, y);
- glVertex2i(x+w, y+h);
- glVertex2i(x, y+h);
- glEnd();
+glBegin(GL_LINE_LOOP);
+glColor4ub(r, g, b, a);
+glVertex2i(x, y);
+glVertex2i(x+w, y);
+glVertex2i(x+w, y+h);
+glVertex2i(x, y+h);
+glEnd();
#else
- int i;
- for (i=0; i<=w; i++)
- {
- drawpixel(vid, x+i, y, r, g, b, a);
- drawpixel(vid, x+i, y+h, r, g, b, a);
- }
- for (i=1; i<h; i++)
- {
- drawpixel(vid, x, y+i, r, g, b, a);
- drawpixel(vid, x+w, y+i, r, g, b, a);
- }
+int i;
+for (i=0; i<=w; i++)
+{
+ drawpixel(vid, x+i, y, r, g, b, a);
+ drawpixel(vid, x+i, y+h, r, g, b, a);
+}
+for (i=1; i<h; i++)
+{
+ drawpixel(vid, x, y+i, r, g, b, a);
+ drawpixel(vid, x+w, y+i, r, g, b, a);
+}
#endif
}
@@ -1204,190 +1241,190 @@ void drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a
void fillrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a)
{
#ifdef OpenGL
- glBegin(GL_QUADS);
- glColor4ub(r, g, b, a);
- glVertex2i(x, y);
- glVertex2i(x+w, y);
- glVertex2i(x+w, y+h);
- glVertex2i(x, y+h);
- glEnd();
+glBegin(GL_QUADS);
+glColor4ub(r, g, b, a);
+glVertex2i(x, y);
+glVertex2i(x+w, y);
+glVertex2i(x+w, y+h);
+glVertex2i(x, y+h);
+glEnd();
#else
- int i,j;
- for (j=1; j<h; j++)
- for (i=1; i<w; i++)
- drawpixel(vid, x+i, y+j, r, g, b, a);
+int i,j;
+for (j=1; j<h; j++)
+ for (i=1; i<w; i++)
+ drawpixel(vid, x+i, y+j, r, g, b, a);
#endif // OpenGL
}
void clearrect(pixel *vid, int x, int y, int w, int h)
{
- int i;
- for (i=1; i<h; i++)
- memset(vid+(x+1+(XRES+BARSIZE)*(y+i)), 0, PIXELSIZE*(w-1));
+int i;
+for (i=1; i<h; i++)
+ memset(vid+(x+1+(XRES+BARSIZE)*(y+i)), 0, PIXELSIZE*(w-1));
}
//draws a line of dots, where h is the height. (why is this even here)
void drawdots(pixel *vid, int x, int y, int h, int r, int g, int b, int a)
{
#ifdef OpenGL
- int i;
- glBegin(GL_QUADS);
- glColor4ub(r, g, b, a);
- for (i = 0; i <= h; i +=2)
- glVertex2i(x, y+i);
- glEnd();
+int i;
+glBegin(GL_QUADS);
+glColor4ub(r, g, b, a);
+for (i = 0; i <= h; i +=2)
+ glVertex2i(x, y+i);
+glEnd();
#else
- int i;
- for (i=0; i<=h; i+=2)
- drawpixel(vid, x, y+i, r, g, b, a);
+int i;
+for (i=0; i<=h; i+=2)
+ drawpixel(vid, x, y+i, r, g, b, a);
#endif //OpenGL
}
int textwidth(char *s)
{
- int x = 0;
- for (; *s; s++)
- x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- return x-1;
+int x = 0;
+for (; *s; s++)
+ x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+return x-1;
}
int drawtextmax(pixel *vid, int x, int y, int w, char *s, int r, int g, int b, int a)
{
- int i;
- w += x-5;
- for (; *s; s++)
- {
- if (x+font_data[font_ptrs[(int)(*(unsigned char *)s)]]>=w && x+textwidth(s)>=w+5)
- break;
- x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
- }
- if (*s)
- for (i=0; i<3; i++)
- x = drawchar(vid, x, y, '.', r, g, b, a);
- return x;
+int i;
+w += x-5;
+for (; *s; s++)
+{
+ if (x+font_data[font_ptrs[(int)(*(unsigned char *)s)]]>=w && x+textwidth(s)>=w+5)
+ break;
+ x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
+}
+if (*s)
+ for (i=0; i<3; i++)
+ x = drawchar(vid, x, y, '.', r, g, b, a);
+return x;
}
int textnwidth(char *s, int n)
{
- int x = 0;
- for (; *s; s++)
- {
- if (!n)
- break;
- x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- n--;
- }
- return x-1;
+int x = 0;
+for (; *s; s++)
+{
+ if (!n)
+ break;
+ x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ n--;
+}
+return x-1;
}
void textnpos(char *s, int n, int w, int *cx, int *cy)
{
- int x = 0;
- int y = 0;
- int wordlen, charspace;
- while (*s&&n)
+int x = 0;
+int y = 0;
+int wordlen, charspace;
+while (*s&&n)
+{
+ wordlen = strcspn(s," .,!?\n");
+ charspace = textwidthx(s, w-x);
+ if (charspace<wordlen && wordlen && w-x<w/3)
+ {
+ x = 0;
+ y += FONT_H+2;
+ }
+ for (; *s && --wordlen>=-1; s++)
{
- wordlen = strcspn(s," .,!?\n");
- charspace = textwidthx(s, w-x);
- if (charspace<wordlen && wordlen && w-x<w/3)
+ if (!n) {
+ break;
+ }
+ x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if (x>=w)
{
x = 0;
y += FONT_H+2;
}
- for (; *s && --wordlen>=-1; s++)
- {
- if (!n) {
- break;
- }
- x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if (x>=w)
- {
- x = 0;
- y += FONT_H+2;
- }
- n--;
- }
+ n--;
}
- *cx = x-1;
- *cy = y;
+}
+*cx = x-1;
+*cy = y;
}
int textwidthx(char *s, int w)
{
- int x=0,n=0,cw;
- for (; *s; s++)
- {
- cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if (x+(cw/2) >= w)
- break;
- x += cw;
- n++;
- }
- return n;
+int x=0,n=0,cw;
+for (; *s; s++)
+{
+ cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if (x+(cw/2) >= w)
+ break;
+ x += cw;
+ n++;
+}
+return n;
}
int textposxy(char *s, int width, int w, int h)
{
- int x=0,y=0,n=0,cw, wordlen, charspace;
- while (*s)
+int x=0,y=0,n=0,cw, wordlen, charspace;
+while (*s)
+{
+ wordlen = strcspn(s," .,!?\n");
+ charspace = textwidthx(s, width-x);
+ if (charspace<wordlen && wordlen && width-x<width/3)
{
- wordlen = strcspn(s," .,!?\n");
- charspace = textwidthx(s, width-x);
- if (charspace<wordlen && wordlen && width-x<width/3)
- {
+ x = 0;
+ y += FONT_H+2;
+ }
+ for (; *s && --wordlen>=-1; s++)
+ {
+ cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if ((x+(cw/2) >= w && y+6 >= h)||(y+6 >= h+FONT_H+2))
+ return n++;
+ x += cw;
+ if (x>=width) {
x = 0;
y += FONT_H+2;
}
- for (; *s && --wordlen>=-1; s++)
- {
- cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if ((x+(cw/2) >= w && y+6 >= h)||(y+6 >= h+FONT_H+2))
- return n++;
- x += cw;
- if (x>=width) {
- x = 0;
- y += FONT_H+2;
- }
- n++;
- }
+ n++;
}
- return n;
+}
+return n;
}
int textwrapheight(char *s, int width)
{
- int x=0, height=FONT_H+2, cw;
- int wordlen;
- int charspace;
- while (*s)
+int x=0, height=FONT_H+2, cw;
+int wordlen;
+int charspace;
+while (*s)
+{
+ wordlen = strcspn(s," .,!?\n");
+ charspace = textwidthx(s, width-x);
+ if (charspace<wordlen && wordlen && width-x<width/3)
{
- wordlen = strcspn(s," .,!?\n");
- charspace = textwidthx(s, width-x);
- if (charspace<wordlen && wordlen && width-x<width/3)
+ x = 0;
+ height += FONT_H+2;
+ }
+ for (; *s && --wordlen>=-1; s++)
+ {
+ if (*s == '\n')
{
x = 0;
height += FONT_H+2;
}
- for (; *s && --wordlen>=-1; s++)
+ else if (*s == '\b')
+ {
+ s++;
+ }
+ else
{
- if (*s == '\n')
+ cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if (x+cw>=width)
{
x = 0;
height += FONT_H+2;
}
- else if (*s == '\b')
- {
- s++;
- }
- else
- {
- cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if (x+cw>=width)
- {
- x = 0;
- height += FONT_H+2;
- }
- x += cw;
- }
+ x += cw;
}
}
- return height;
+}
+return height;
}
//the most used function for drawing a pixel, because it has OpenGL support, which is not fully implemented.
@@ -1424,120 +1461,127 @@ inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a)
void draw_icon(pixel *vid_buf, int x, int y, char ch, int flag)
{
- char t[2];
- t[0] = ch;
- t[1] = 0;
- if (flag)
- {
- fillrect(vid_buf, x-1, y-1, 17, 17, 255, 255, 255, 255);
- drawtext(vid_buf, x+3, y+2, t, 0, 0, 0, 255);
- }
- else
- {
- drawrect(vid_buf, x, y, 15, 15, 255, 255, 255, 255);
- drawtext(vid_buf, x+3, y+2, t, 255, 255, 255, 255);
- }
+char t[2];
+t[0] = ch;
+t[1] = 0;
+if (flag)
+{
+ fillrect(vid_buf, x-1, y-1, 17, 17, 255, 255, 255, 255);
+ drawtext(vid_buf, x+3, y+2, t, 0, 0, 0, 255);
+}
+else
+{
+ drawrect(vid_buf, x, y, 15, 15, 255, 255, 255, 255);
+ drawtext(vid_buf, x+3, y+2, t, 255, 255, 255, 255);
+}
}
void draw_air(pixel *vid)
{
- int x, y, i, j;
- pixel c;
+int x, y, i, j;
+pixel c;
- if (cmode == CM_PERS)//this should never happen anyway
- return;
+if (cmode == CM_PERS)//this should never happen anyway
+ return;
- for (y=0; y<YRES/CELL; y++)
- for (x=0; x<XRES/CELL; x++)
+for (y=0; y<YRES/CELL; y++)
+ for (x=0; x<XRES/CELL; x++)
+ {
+ if (cmode == CM_PRESS)
{
- if (cmode == CM_PRESS)
- {
- if (pv[y][x] > 0.0f)
- c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0);//positive pressure is red!
- else
- c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));//negative pressure is blue!
- }
- else if (cmode == CM_VEL)
- {
- c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
- clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green
- clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
- }
- else if (cmode == CM_HEAT && aheat_enable)
+ if (pv[y][x] > 0.0f)
+ c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0);//positive pressure is red!
+ else
+ c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));//negative pressure is blue!
+ }
+ else if (cmode == CM_VEL)
+ {
+ c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
+ clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green
+ clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
+ }
+ else if (cmode == CM_HEAT && aheat_enable)
+ {
+ float ttemp = hv[y][x]+(-MIN_TEMP);
+ int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
+ c = PIXRGB((int)((unsigned char)color_data[caddress]*0.7f), (int)((unsigned char)color_data[caddress+1]*0.7f), (int)((unsigned char)color_data[caddress+2]*0.7f));
+ //c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
+ // clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
+ // clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
+ }
+ else if (cmode == CM_CRACK)
+ {
+ int r;
+ int g;
+ int b;
+ // velocity adds grey
+ r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f);
+ b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ if (pv[y][x] > 0.0f)
{
- float ttemp = hv[y][x]+(-MIN_TEMP);
- int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
- c = PIXRGB((int)((unsigned char)color_data[caddress]*0.7f), (int)((unsigned char)color_data[caddress+1]*0.7f), (int)((unsigned char)color_data[caddress+2]*0.7f));
- //c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
- // clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
- // clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
+ r += clamp_flt(pv[y][x], 0.0f, 16.0f);//pressure adds red!
+ if (r>255)
+ r=255;
+ if (g>255)
+ g=255;
+ if (b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
}
- else if (cmode == CM_CRACK)
+ else
{
- int r;
- int g;
- int b;
- // velocity adds grey
- r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
- g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f);
- b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
- if (pv[y][x] > 0.0f)
- {
- r += clamp_flt(pv[y][x], 0.0f, 16.0f);//pressure adds red!
- if (r>255)
- r=255;
- if (g>255)
- g=255;
- if (b>255)
- b=255;
- c = PIXRGB(r, g, b);
- }
- else
- {
- b += clamp_flt(-pv[y][x], 0.0f, 16.0f);//pressure adds blue!
- if (r>255)
- r=255;
- if (g>255)
- g=255;
- if (b>255)
- b=255;
- c = PIXRGB(r, g, b);
- }
+ b += clamp_flt(-pv[y][x], 0.0f, 16.0f);//pressure adds blue!
+ if (r>255)
+ r=255;
+ if (g>255)
+ g=255;
+ if (b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
}
- for (j=0; j<CELL; j++)//draws the colors
- for (i=0; i<CELL; i++)
- vid[(x*CELL+i) + (y*CELL+j)*(XRES+BARSIZE)] = c;
}
+ for (j=0; j<CELL; j++)//draws the colors
+ for (i=0; i<CELL; i++)
+ vid[(x*CELL+i) + (y*CELL+j)*(XRES+BARSIZE)] = c;
+ }
}
void draw_grav_zones(pixel * vid)
{
- int x, y, i, j;
- for (y=0; y<YRES/CELL; y++)
+int x, y, i, j;
+for (y=0; y<YRES/CELL; y++)
+{
+ for (x=0; x<XRES/CELL; x++)
{
- for (x=0; x<XRES/CELL; x++)
+ if(gravmask[y][x])
{
- if(gravmask[y][x])
- {
- for (j=0; j<CELL; j++)//draws the colors
- for (i=0; i<CELL; i++)
- if(i == j)
- drawpixel(vid, x*CELL+i, y*CELL+j, 255, 200, 0, 120);
- else
- drawpixel(vid, x*CELL+i, y*CELL+j, 32, 32, 32, 120);
- }
+ for (j=0; j<CELL; j++)//draws the colors
+ for (i=0; i<CELL; i++)
+ if(i == j)
+ drawpixel(vid, x*CELL+i, y*CELL+j, 255, 200, 0, 120);
+ else
+ drawpixel(vid, x*CELL+i, y*CELL+j, 32, 32, 32, 120);
}
}
}
+}
void draw_grav(pixel *vid)
{
int x, y, i, ca;
float nx, ny, dist;
- for (y=0; y<YRES/CELL; y++)
+for (y=0; y<YRES/CELL; y++)
+{
+ for (x=0; x<XRES/CELL; x++)
{
- for (x=0; x<XRES/CELL; x++)
+ if(fabsf(gravx[y][x]) <= 0.001f && fabsf(gravy[y][x]) <= 0.001f)
+ continue;
+ nx = x*CELL;
+ ny = y*CELL;
+ dist = fabsf(gravx[y][x])+fabsf(gravy[y][x]);
+ for(i = 0; i < 4; i++)
{
ca = ((y*CELL)*XRES)+(x*CELL);
if(fabsf(gravpf[ca]) <= 0.001f && fabsf(gravyf[ca]) <= 0.001f)
@@ -1554,189 +1598,190 @@ void draw_grav(pixel *vid)
}
}
}
+}
void draw_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a) //Draws a line
{
- int dx, dy, i, sx, sy, check, e, x, y;
+int dx, dy, i, sx, sy, check, e, x, y;
- dx = abs(x1-x2);
- dy = abs(y1-y2);
- sx = isign(x2-x1);
- sy = isign(y2-y1);
- x = x1;
- y = y1;
- check = 0;
+dx = abs(x1-x2);
+dy = abs(y1-y2);
+sx = isign(x2-x1);
+sy = isign(y2-y1);
+x = x1;
+y = y1;
+check = 0;
- if (dy>dx)
- {
- dx = dx+dy;
- dy = dx-dy;
- dx = dx-dy;
- check = 1;
- }
+if (dy>dx)
+{
+ dx = dx+dy;
+ dy = dx-dy;
+ dx = dx-dy;
+ check = 1;
+}
- e = (dy<<2)-dx;
- for (i=0; i<=dx; i++)
+e = (dy<<2)-dx;
+for (i=0; i<=dx; i++)
+{
+ if (x>=0 && y>=0 && x<a && y<YRES+MENUSIZE)
+ vid[x+y*a] =PIXRGB(r, g, b);
+ if (e>=0)
{
- if (x>=0 && y>=0 && x<a && y<YRES+MENUSIZE)
- vid[x+y*a] =PIXRGB(r, g, b);
- if (e>=0)
- {
- if (check==1)
- x = x+sx;
- else
- y = y+sy;
- e = e-(dx<<2);
- }
if (check==1)
- y = y+sy;
- else
x = x+sx;
- e = e+(dy<<2);
+ else
+ y = y+sy;
+ e = e-(dx<<2);
}
+ if (check==1)
+ y = y+sy;
+ else
+ x = x+sx;
+ e = e+(dy<<2);
+}
}
//adds color to a pixel, does not overwrite.
void addpixel(pixel *vid, int x, int y, int r, int g, int b, int a)
{
- pixel t;
- if (x<0 || y<0 || x>=XRES || y>=YRES)
- return;
- t = vid[y*(XRES+BARSIZE)+x];
- r = (a*r + 255*PIXR(t)) >> 8;
- g = (a*g + 255*PIXG(t)) >> 8;
- b = (a*b + 255*PIXB(t)) >> 8;
- if (r>255)
- r = 255;
- if (g>255)
- g = 255;
- if (b>255)
- b = 255;
- vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b);
+pixel t;
+if (x<0 || y<0 || x>=XRES || y>=YRES)
+ return;
+t = vid[y*(XRES+BARSIZE)+x];
+r = (a*r + 255*PIXR(t)) >> 8;
+g = (a*g + 255*PIXG(t)) >> 8;
+b = (a*b + 255*PIXB(t)) >> 8;
+if (r>255)
+ r = 255;
+if (g>255)
+ g = 255;
+if (b>255)
+ b = 255;
+vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b);
}
//draws one of two colors, so that it is always clearly visible
void xor_pixel(int x, int y, pixel *vid)
{
- int c;
- if (x<0 || y<0 || x>=XRES || y>=YRES)
- return;
- c = vid[y*(XRES+BARSIZE)+x];
- c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c);
- if (c<512)
- vid[y*(XRES+BARSIZE)+x] = PIXPACK(0xC0C0C0);
- else
- vid[y*(XRES+BARSIZE)+x] = PIXPACK(0x404040);
+int c;
+if (x<0 || y<0 || x>=XRES || y>=YRES)
+ return;
+c = vid[y*(XRES+BARSIZE)+x];
+c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c);
+if (c<512)
+ vid[y*(XRES+BARSIZE)+x] = PIXPACK(0xC0C0C0);
+else
+ vid[y*(XRES+BARSIZE)+x] = PIXPACK(0x404040);
}
//same as xor_pixel, but draws a line of it
void xor_line(int x1, int y1, int x2, int y2, pixel *vid)
{
- int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
- float e, de;
+int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
+float e, de;
+if (cp)
+{
+ y = x1;
+ x1 = y1;
+ y1 = y;
+ y = x2;
+ x2 = y2;
+ y2 = y;
+}
+if (x1 > x2)
+{
+ y = x1;
+ x1 = x2;
+ x2 = y;
+ y = y1;
+ y1 = y2;
+ y2 = y;
+}
+dx = x2 - x1;
+dy = abs(y2 - y1);
+e = 0.0f;
+if (dx)
+ de = dy/(float)dx;
+else
+ de = 0.0f;
+y = y1;
+sy = (y1<y2) ? 1 : -1;
+for (x=x1; x<=x2; x++)
+{
if (cp)
- {
- y = x1;
- x1 = y1;
- y1 = y;
- y = x2;
- x2 = y2;
- y2 = y;
- }
- if (x1 > x2)
- {
- y = x1;
- x1 = x2;
- x2 = y;
- y = y1;
- y1 = y2;
- y2 = y;
- }
- dx = x2 - x1;
- dy = abs(y2 - y1);
- e = 0.0f;
- if (dx)
- de = dy/(float)dx;
+ xor_pixel(y, x, vid);
else
- de = 0.0f;
- y = y1;
- sy = (y1<y2) ? 1 : -1;
- for (x=x1; x<=x2; x++)
+ xor_pixel(x, y, vid);
+ e += de;
+ if (e >= 0.5f)
{
- if (cp)
- xor_pixel(y, x, vid);
- else
- xor_pixel(x, y, vid);
- e += de;
- if (e >= 0.5f)
- {
- y += sy;
- e -= 1.0f;
- }
+ y += sy;
+ e -= 1.0f;
}
}
+}
//same as blend_pixel, but draws a line of it
void blend_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a)
{
- int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
- float e, de;
+int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
+float e, de;
+if (cp)
+{
+ y = x1;
+ x1 = y1;
+ y1 = y;
+ y = x2;
+ x2 = y2;
+ y2 = y;
+}
+if (x1 > x2)
+{
+ y = x1;
+ x1 = x2;
+ x2 = y;
+ y = y1;
+ y1 = y2;
+ y2 = y;
+}
+dx = x2 - x1;
+dy = abs(y2 - y1);
+e = 0.0f;
+if (dx)
+ de = dy/(float)dx;
+else
+ de = 0.0f;
+y = y1;
+sy = (y1<y2) ? 1 : -1;
+for (x=x1; x<=x2; x++)
+{
if (cp)
- {
- y = x1;
- x1 = y1;
- y1 = y;
- y = x2;
- x2 = y2;
- y2 = y;
- }
- if (x1 > x2)
- {
- y = x1;
- x1 = x2;
- x2 = y;
- y = y1;
- y1 = y2;
- y2 = y;
- }
- dx = x2 - x1;
- dy = abs(y2 - y1);
- e = 0.0f;
- if (dx)
- de = dy/(float)dx;
+ blendpixel(vid, y, x, r, g, b, a);
else
- de = 0.0f;
- y = y1;
- sy = (y1<y2) ? 1 : -1;
- for (x=x1; x<=x2; x++)
+ blendpixel(vid, x, y, r, g, b, a);
+ e += de;
+ if (e >= 0.5f)
{
- if (cp)
- blendpixel(vid, y, x, r, g, b, a);
- else
- blendpixel(vid, x, y, r, g, b, a);
- e += de;
- if (e >= 0.5f)
- {
- y += sy;
- e -= 1.0f;
- }
+ y += sy;
+ e -= 1.0f;
}
}
+}
//same as xor_pixel, but draws a rectangle
void xor_rect(pixel *vid, int x, int y, int w, int h)
{
- int i;
- for (i=0; i<w; i+=2)
- {
- xor_pixel(x+i, y, vid);
- xor_pixel(x+i, y+h-1, vid);
- }
- for (i=2; i<h; i+=2)
- {
- xor_pixel(x, y+i, vid);
- xor_pixel(x+w-1, y+i, vid);
- }
+int i;
+for (i=0; i<w; i+=2)
+{
+ xor_pixel(x+i, y, vid);
+ xor_pixel(x+i, y+h-1, vid);
+}
+for (i=2; i<h; i+=2)
+{
+ xor_pixel(x, y+i, vid);
+ xor_pixel(x+w-1, y+i, vid);
+}
}
void draw_other(pixel *vid) // EMP effect
@@ -1787,137 +1832,172 @@ void draw_parts(pixel *vid)
#ifdef OpenGL
if (cmode == CM_FANCY) //If fancy mode
{
+ if (ny%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ if (nx%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ }
+}
+for (i = 0; i<=parts_lastActiveIndex; i++) {
+#ifdef OpenGL
+ if (cmode == CM_FANCY) //If fancy mode
+ {
- if (t==PT_MWAX)
+ if (t==PT_MWAX)
+ {
+ for (x=-1; x<=1; x++)
{
- for (x=-1; x<=1; x++)
+ for (y=-1; y<=1; y++)
{
- for (y=-1; y<=1; y++)
- {
- if ((abs(x) == 0) && (abs(y) == 0))
- blendpixel(vid,x+nx,y+ny,224,224,170,255);
- else if (abs(y) != 0 && abs(x) != 0)
- blendpixel(vid,x+nx,y+ny,224,224,170,20);
- else
- blendpixel(vid,x+nx,y+ny,224,224,170,40);
- }
+ if ((abs(x) == 0) && (abs(y) == 0))
+ blendpixel(vid,x+nx,y+ny,224,224,170,255);
+ else if (abs(y) != 0 && abs(x) != 0)
+ blendpixel(vid,x+nx,y+ny,224,224,170,20);
+ else
+ blendpixel(vid,x+nx,y+ny,224,224,170,40);
}
-
}
- else if (t==PT_PLUT)
- {
- int tempx;
- int tempy;
- cr = 0x40;
- cg = 0x70;
- cb = 0x20;
- blendpixel(vid, nx, ny, cr, cg, cb, 192);
- blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
- blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
- blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
- for (tempx = 2; tempx < 10; tempx++) {
- for (tempy = 2; tempy < 10; tempy++) {
- blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
- blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
- }
+ }
+
+ else if (t==PT_PLUT)
+ {
+ int tempx;
+ int tempy;
+ cr = 0x40;
+ cg = 0x70;
+ cb = 0x20;
+ blendpixel(vid, nx, ny, cr, cg, cb, 192);
+ blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
+ blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
+ for (tempx = 2; tempx < 10; tempx++) {
+ for (tempy = 2; tempy < 10; tempy++) {
+ blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
+ blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
}
- if (parts[i].type) {
- //Do nothing
- t = parts[i].type;
- nx = (int)(parts[i].x+0.5f);
- ny = (int)(parts[i].y+0.5f);
- glBegin (GL_POINTS);
- glColor3ub (PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors));
- glVertex2d (nx, ny);
- glEnd ();
- }
+ }
+ if (parts[i].type) {
+ //Do nothing
+ t = parts[i].type;
+ nx = (int)(parts[i].x+0.5f);
+ ny = (int)(parts[i].y+0.5f);
+ glBegin (GL_POINTS);
+ glColor3ub (PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors));
+ glVertex2d (nx, ny);
+ glEnd ();
+ }
#else
- if (parts[i].type) {
- t = parts[i].type;
+ if (parts[i].type) {
+ t = parts[i].type;
- nx = (int)(parts[i].x+0.5f);
- ny = (int)(parts[i].y+0.5f);
+ nx = (int)(parts[i].x+0.5f);
+ ny = (int)(parts[i].y+0.5f);
- if(photons[ny][nx]&0xFF && !(ptypes[t].properties & TYPE_ENERGY))
- continue;
-
- if (t==PT_SOAP)
- {
- if ((parts[i].ctype&7) == 7)
- draw_line(vid, nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), 245, 245, 220, XRES+BARSIZE);
- }
-
- if(t==PT_WIRE)
- {
- if (parts[i].ctype==0)
- blendpixel(vid, nx, ny, 255, 204, 0, 255);
- else if(parts[i].ctype==1)
- blendpixel(vid, nx, ny, 0, 0, 255, 255);
- else
- blendpixel(vid, nx, ny, 255, 255, 255, 255);
-
+ if(photons[ny][nx]&0xFF && !(ptypes[t].properties & TYPE_ENERGY))
continue;
- }
- if (cmode!=CM_HEAT)
+ if (t==PT_SOAP)
+ {
+ if ((parts[i].ctype&7) == 7)
+ draw_line(vid, nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), 245, 245, 220, XRES+BARSIZE);
+ }
+
+ if(t==PT_WIRE)
+ {
+ if (parts[i].ctype==0)
+ blendpixel(vid, nx, ny, 255, 204, 0, 255);
+ else if(parts[i].ctype==1)
+ blendpixel(vid, nx, ny, 0, 0, 255, 255);
+ else
+ blendpixel(vid, nx, ny, 255, 255, 255, 255);
+
+ continue;
+ }
+
+ if (cmode!=CM_HEAT)
+ {
+ if (t==PT_STKM)
{
- if (t==PT_STKM)
+ char buff[20]; //Buffer for HP
+ pixel pc;
+
+ if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
{
- char buff[20]; //Buffer for HP
- pixel pc;
+ 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);
+ }
- 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);
- }
+ if ((int)player[2]<PT_NUM) pc = ptypes[(int)player[2]].pcolors;
+ else pc = PIXPACK(0xFFFFFF);
+ s = XRES+BARSIZE;
+ //head
+ draw_line(vid , nx-2, ny+2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx-2, ny-2, nx+2, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx-2, ny-2, nx-2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx+2, ny-2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ //legs
+ draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s);
+ draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s);
+ draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s);
+ draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s);
+ }
+ else if (t==PT_STKM2)
+ {
+ char buff[20]; //Buffer for HP
+ pixel pc;
- if ((int)player[2]<PT_NUM) pc = ptypes[(int)player[2]].pcolors;
- else pc = PIXPACK(0xFFFFFF);
- s = XRES+BARSIZE;
- //head
- draw_line(vid , nx-2, ny+2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx-2, ny-2, nx+2, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx-2, ny-2, nx-2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx+2, ny-2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- //legs
- draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s);
- draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s);
- draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s);
- draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s);
- }
- else if (t==PT_STKM2)
+ if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head
{
- char buff[20]; //Buffer for HP
- pixel pc;
+ 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);
+ }
- 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);
- }
+ if ((int)player2[2]<PT_NUM) pc = ptypes[(int)player2[2]].pcolors;
+ else pc = PIXPACK(0xFFFFFF);
+ s = XRES+BARSIZE;
+ //head
+ draw_line(vid , nx-2, ny+2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx-2, ny-2, nx+2, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx-2, ny-2, nx-2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx+2, ny-2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ //legs
+ 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);
+ }
+ else if (t==PT_FIGH) //Fighter should be visible in heat mode
+ {
+ char buff[10]; //Buffer for HP
+ pixel pc;
+ float *figh = fighters[(unsigned char)parts[i].tmp];
- if ((int)player2[2]<PT_NUM) pc = ptypes[(int)player2[2]].pcolors;
- else pc = PIXPACK(0xFFFFFF);
- s = XRES+BARSIZE;
- //head
- draw_line(vid , nx-2, ny+2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx-2, ny-2, nx+2, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx-2, ny-2, nx-2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- draw_line(vid , nx+2, ny-2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
- //legs
- 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);
+ 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);
}
- if (cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_GPMP && t!=PT_PBCN && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI && t!=PT_LIFE && t!=PT_PVOD)//nothing display but show needed color changes
+ if ((int)figh[2]<PT_NUM) pc = ptypes[(int)figh[2]].pcolors;
+ else pc = PIXPACK(0xFFFFFF);
+ s = XRES+BARSIZE;
+ //head
+ draw_line(vid , nx, ny+2, nx+2, ny, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx+2, ny, nx, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx, ny-2, nx-2, ny, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ draw_line(vid , nx-2, ny, nx, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s);
+ //legs
+ draw_line(vid , nx, ny+3, figh[3], figh[4], 255, 255, 255, s);
+ draw_line(vid , figh[3], figh[4], figh[7], figh[8], 255, 255, 255, s);
+ draw_line(vid , nx, ny+3, figh[11], figh[12], 255, 255, 255, s);
+ draw_line(vid , figh[11], figh[12], figh[15], figh[16], 255, 255, 255, s);
+ }
+ if (cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_GPMP && t!=PT_PBCN && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI && t!=PT_LIFE)//nothing display but show needed color changes
{
if (t==PT_PHOT)
{
@@ -3835,6 +3915,29 @@ void draw_parts(pixel *vid)
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);
}
+ else if (t==PT_FIGH) //Fighter should be visible in heat mode
+ {
+ char buff[10]; //Buffer for HP
+ float *figh = fighters[(unsigned char)parts[i].tmp];
+
+ 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);
+ }
+
+ s = XRES+BARSIZE;
+ //head
+ draw_line(vid , nx, ny+2, nx+2, ny, R, G, B, s);
+ draw_line(vid , nx+2, ny, nx, ny-2, R, G, B, s);
+ draw_line(vid , nx, ny-2, nx-2, ny, R, G, B, s);
+ draw_line(vid , nx-2, ny, nx, ny+2, R, G, B, s);
+ //legs
+ draw_line(vid , nx, ny+3, figh[3], figh[4], R, G, B, s);
+ draw_line(vid , figh[3], figh[4], figh[7], figh[8], R, G, B, s);
+ draw_line(vid , nx, ny+3, figh[11], figh[12], R, G, B, s);
+ draw_line(vid , figh[11], figh[12], figh[15], figh[16], R, G, B, s);
+ }
else
{
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B);
@@ -4706,10 +4809,10 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
j=d[p++];
if (j<PT_NUM && j>0)
{
- if (j==PT_STKM || j==PT_STKM2)
+ if (j==PT_STKM || j==PT_STKM2 || j==PT_FIGH)
{
pixel lc, hc=PIXRGB(255, 224, 178);
- if (j==PT_STKM) lc = PIXRGB(255, 255, 255);
+ if (j==PT_STKM || j==PT_FIGH) lc = PIXRGB(255, 255, 255);
else lc = PIXRGB(100, 100, 255);
//only need to check upper bound of y coord - lower bounds and x<w are checked in draw_line
draw_line(fb , x-2, y-2, x+2, y-2, PIXR(hc), PIXG(hc), PIXB(hc), w);
diff --git a/src/main.c b/src/main.c
index 4b6d413..935be55 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1113,6 +1113,8 @@ void clear_sim(void)
memset(wireless, 0, sizeof(wireless));
memset(gol2, 0, sizeof(gol2));
memset(portalp, 0, sizeof(portalp));
+ memset(fighters, 0, sizeof(fighters));
+ fighcount = 0;
ISSPAWN1 = ISSPAWN2 = 0;
player[27] = 0;
player2[27] = 0;
@@ -3115,7 +3117,7 @@ int main(int argc, char *argv[])
c = (b&1) ? sl : sr; //c is element to be spawned
su = c;
- if (c!=WL_SIGN+100)
+ if (c!=WL_SIGN+100 && c!=PT_FIGH)
{
if (!bq)
for (signi=0; signi<MAXSIGNS; signi++)
@@ -3144,6 +3146,12 @@ int main(int argc, char *argv[])
if (!bq)
add_sign_ui(vid_buf, x, y);
}
+
+ if (c==PT_FIGH)
+ {
+ if (!bq)
+ create_part(-1, x, y, PT_FIGH);
+ }
//for the click functions, lx and ly, are the positions of where the FIRST click happened. x,y are current mouse position.
else if (lb)//lb means you are holding mouse down
{
diff --git a/src/powder.c b/src/powder.c
index bf31b18..e5680eb 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -16,6 +16,9 @@ int lighting_recreate = 0;
float player[29];
float player2[29];
+float fighters[256][28]; //255 is the maximum number of fighters
+unsigned char fighcount = 0; //Contains the number of fighters
+
particle *parts;
particle *cb_parts;
@@ -110,6 +113,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function
can_move[PT_STKM][t] = 2;
can_move[PT_STKM2][t] = 2;
+ can_move[PT_FIGH][t] = 2;
}
for (t=0;t<PT_NUM;t++)
{
@@ -120,6 +124,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function
can_move[t][PT_STKM] = 2;
can_move[t][PT_STKM2] = 2;
+ can_move[PT_FIGH][t] = 2;
//INVIS behaviour varies with pressure
can_move[t][PT_INVIS] = 3;
//stop CNCT being displaced by other particles
@@ -310,6 +315,11 @@ int try_move(int i, int x, int y, int nx, int ny)
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
parts[i].type=PT_NONE;
return 0;
}
@@ -323,6 +333,11 @@ int try_move(int i, int x, int y, int nx, int ny)
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
parts[i].type=PT_NONE;
if (!legacy_enable)
{
@@ -592,6 +607,11 @@ void kill_part(int i)//kills particle number i
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
if (parts[i].type == PT_SPAWN)
{
ISSPAWN1 = 0;
@@ -633,6 +653,12 @@ inline void part_change_type(int i, int x, int y, int t)//changes the type of pa
if (parts[i].type == PT_STKM2)
player2[27] = 0;
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
+
parts[i].type = t;
if (t==PT_PHOT || t==PT_NEUT)
{
@@ -761,7 +787,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
if ((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
{
- if (t!=PT_STKM&&t!=PT_STKM2)
+ if (t!=PT_STKM&&t!=PT_STKM2&&t!=PT_FIGH)
{
return -1;
}
@@ -787,7 +813,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
t!=PT_CLNE&&t!=PT_PCLN&&
t!=PT_BCLN&&t!=PT_STKM&&
t!=PT_STKM2&&t!=PT_PBCN&&
- t!=PT_STOR)
+ t!=PT_STOR&&t!=PT_FIGH)
)
{
parts[pmap[y][x]>>8].ctype = t;
@@ -836,7 +862,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
parts[i].pavg[0] = 0.0f;
parts[i].pavg[1] = 0.0f;
}
- if (t!=PT_STKM&&t!=PT_STKM2)//set everything to default values first, except for stickman.
+ if (t!=PT_STKM&&t!=PT_STKM2&&t!=PT_FIGH)//set everything to default values first, except for stickman.
{
parts[i].x = (float)x;
parts[i].y = (float)y;
@@ -1003,12 +1029,36 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
create_part(-1,x,y,PT_SPAWN2);
ISSPAWN2 = 1;
}
+ if (t==PT_FIGH)
+ {
+ unsigned char cunt = 0;
+ while (cunt < 100 && cunt < (fighcount+1) && fighters[cunt][27]==1) cunt++;
+ if (cunt < 100 && fighters[cunt][27]==0)
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_FIGH;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].tmp = cunt;
+ parts[i].temp = ptypes[t].heat;
+ STKM_init_legs(fighters[cunt], i);
+ fighters[cunt][27] = 1;
+ fighters[cunt][2] = PT_DUST;
+ fighcount++;
+
+ return i;
+ }
+ return -1;
+ }
if (t==PT_BIZR||t==PT_BIZRG)
parts[i].ctype = 0x47FFFF;
//and finally set the pmap/photon maps to the newly created particle
if (t==PT_PHOT||t==PT_NEUT)
photons[y][x] = t|(i<<8);
- if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT)
+ if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_FIGH && t!=PT_PHOT && t!=PT_NEUT)
pmap[y][x] = t|(i<<8);
//Fancy dust effects for powder types
@@ -1674,7 +1724,7 @@ void update_particles_i(pixel *vid, int start, int inc)
(bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(ptypes[t].properties&TYPE_GAS)) || //&& 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_ALLOWENERGY && !(ptypes[t].properties&TYPE_ENERGY)) ||
(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) && (t!=PT_STKM2)))
+ (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2) && (t!=PT_FIGH)))
{
kill_part(i);
continue;
@@ -1736,7 +1786,7 @@ void update_particles_i(pixel *vid, int start, int inc)
pGravX -= gravxf[(y*XRES)+x];
pGravY -= gravyf[(y*XRES)+x];
}
- else if(t!=PT_STKM && t!=PT_STKM2 && !(ptypes[t].properties & TYPE_SOLID))
+ else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(ptypes[t].properties & TYPE_SOLID))
{
pGravX += gravxf[(y*XRES)+x];
pGravY += gravyf[(y*XRES)+x];
@@ -2838,7 +2888,7 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
int wall = c - 100;
- if (c==SPC_WIND){
+ if (c==SPC_WIND || c==PT_FIGH)
return 0;
}
if(c==SPC_PROP){