Fix graphics.c
This commit is contained in:
parent
e3a7b626ab
commit
60de1cf575
437
src/graphics.c
437
src/graphics.c
@ -1023,16 +1023,16 @@ inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a)
|
||||
ba >>= 2;
|
||||
bn -= 2;
|
||||
}
|
||||
return x + w;
|
||||
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;
|
||||
@ -1057,6 +1057,10 @@ for (; *s; s++)
|
||||
r = 255;
|
||||
g = b = 0;
|
||||
break;
|
||||
case 'l':
|
||||
r = 255;
|
||||
g = b = 75;
|
||||
break;
|
||||
case 'b':
|
||||
r = g = 0;
|
||||
b = 255;
|
||||
@ -1071,34 +1075,34 @@ for (; *s; s++)
|
||||
}
|
||||
else
|
||||
x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return x;
|
||||
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);
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@ -1117,45 +1121,6 @@ while (*s)
|
||||
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 'l':
|
||||
r = 255;
|
||||
g = b = 75;
|
||||
break;
|
||||
case 'b':
|
||||
r = g = 0;
|
||||
b = 255;
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (x-cw>=w)
|
||||
{
|
||||
x = sx;
|
||||
rw = 0;
|
||||
y += FONT_H+2;
|
||||
}
|
||||
else if (*s == '\b')
|
||||
{
|
||||
switch (s[1])
|
||||
{
|
||||
@ -1202,38 +1167,36 @@ while (*s)
|
||||
}
|
||||
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++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@ -1241,16 +1204,16 @@ for (i=1; i<h; i++)
|
||||
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++)
|
||||
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
|
||||
@ -1258,70 +1221,70 @@ for (j=1; j<h; j++)
|
||||
|
||||
void clearrect(pixel *vid, int x, int y, int w, int h)
|
||||
{
|
||||
int i;
|
||||
for (i=1; i<h; i++)
|
||||
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)
|
||||
int i;
|
||||
glBegin(GL_QUADS);
|
||||
glColor4ub(r, g, b, a);
|
||||
for (i = 0; i <= h; i +=2)
|
||||
glVertex2i(x, y+i);
|
||||
glEnd();
|
||||
glEnd();
|
||||
#else
|
||||
int i;
|
||||
for (i=0; i<=h; i+=2)
|
||||
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++)
|
||||
int x = 0;
|
||||
for (; *s; s++)
|
||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
||||
return x-1;
|
||||
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++)
|
||||
{
|
||||
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)
|
||||
}
|
||||
if (*s)
|
||||
for (i=0; i<3; i++)
|
||||
x = drawchar(vid, x, y, '.', r, g, b, a);
|
||||
return x;
|
||||
return x;
|
||||
}
|
||||
|
||||
int textnwidth(char *s, int n)
|
||||
{
|
||||
int x = 0;
|
||||
for (; *s; s++)
|
||||
{
|
||||
int x = 0;
|
||||
for (; *s; s++)
|
||||
{
|
||||
if (!n)
|
||||
break;
|
||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
||||
n--;
|
||||
}
|
||||
return x-1;
|
||||
}
|
||||
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)
|
||||
@ -1342,29 +1305,29 @@ while (*s&&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++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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)
|
||||
@ -1384,16 +1347,16 @@ while (*s)
|
||||
}
|
||||
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)
|
||||
@ -1423,8 +1386,8 @@ while (*s)
|
||||
x += cw;
|
||||
}
|
||||
}
|
||||
}
|
||||
return height;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
//the most used function for drawing a pixel, because it has OpenGL support, which is not fully implemented.
|
||||
@ -1461,30 +1424,30 @@ 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)
|
||||
{
|
||||
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
|
||||
{
|
||||
}
|
||||
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
|
||||
if (cmode == CM_PERS)//this should never happen anyway
|
||||
return;
|
||||
|
||||
for (y=0; y<YRES/CELL; y++)
|
||||
for (y=0; y<YRES/CELL; y++)
|
||||
for (x=0; x<XRES/CELL; x++)
|
||||
{
|
||||
if (cmode == CM_PRESS)
|
||||
@ -1549,9 +1512,9 @@ for (y=0; y<YRES/CELL; y++)
|
||||
|
||||
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++)
|
||||
{
|
||||
if(gravmask[y][x])
|
||||
@ -1564,7 +1527,7 @@ for (y=0; y<YRES/CELL; y++)
|
||||
drawpixel(vid, x*CELL+i, y*CELL+j, 32, 32, 32, 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_grav(pixel *vid)
|
||||
@ -1572,16 +1535,9 @@ void draw_grav(pixel *vid)
|
||||
int x, y, i, ca;
|
||||
float nx, ny, dist;
|
||||
|
||||
for (y=0; y<YRES/CELL; y++)
|
||||
{
|
||||
for (x=0; x<XRES/CELL; x++)
|
||||
for (y=0; y<YRES/CELL; y++)
|
||||
{
|
||||
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++)
|
||||
for (x=0; x<XRES/CELL; x++)
|
||||
{
|
||||
ca = ((y*CELL)*XRES)+(x*CELL);
|
||||
if(fabsf(gravpf[ca]) <= 0.001f && fabsf(gravyf[ca]) <= 0.001f)
|
||||
@ -1598,31 +1554,30 @@ for (y=0; y<YRES/CELL; y++)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@ -1638,76 +1593,76 @@ for (i=0; i<=dx; i++)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
if (g>255)
|
||||
g = 255;
|
||||
if (b>255)
|
||||
if (b>255)
|
||||
b = 255;
|
||||
vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b);
|
||||
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)
|
||||
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)
|
||||
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
|
||||
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;
|
||||
if (cp)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
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)
|
||||
}
|
||||
dx = x2 - x1;
|
||||
dy = abs(y2 - y1);
|
||||
e = 0.0f;
|
||||
if (dx)
|
||||
de = dy/(float)dx;
|
||||
else
|
||||
else
|
||||
de = 0.0f;
|
||||
y = y1;
|
||||
sy = (y1<y2) ? 1 : -1;
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
y = y1;
|
||||
sy = (y1<y2) ? 1 : -1;
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (cp)
|
||||
xor_pixel(y, x, vid);
|
||||
else
|
||||
@ -1718,43 +1673,43 @@ for (x=x1; x<=x2; x++)
|
||||
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;
|
||||
if (cp)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
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)
|
||||
}
|
||||
dx = x2 - x1;
|
||||
dy = abs(y2 - y1);
|
||||
e = 0.0f;
|
||||
if (dx)
|
||||
de = dy/(float)dx;
|
||||
else
|
||||
else
|
||||
de = 0.0f;
|
||||
y = y1;
|
||||
sy = (y1<y2) ? 1 : -1;
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
y = y1;
|
||||
sy = (y1<y2) ? 1 : -1;
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (cp)
|
||||
blendpixel(vid, y, x, r, g, b, a);
|
||||
else
|
||||
@ -1765,23 +1720,23 @@ for (x=x1; x<=x2; x++)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
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
|
||||
@ -1829,16 +1784,6 @@ void draw_parts(pixel *vid)
|
||||
}
|
||||
}
|
||||
for (i = 0; i<=parts_lastActiveIndex; i++) {
|
||||
#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
|
||||
{
|
||||
@ -1997,7 +1942,7 @@ for (i = 0; i<=parts_lastActiveIndex; i++) {
|
||||
draw_line(vid , nx, ny+3, figh->legs[8], figh->legs[9], 255, 255, 255, s);
|
||||
draw_line(vid , figh->legs[8], figh->legs[9], figh->legs[12], figh->legs[13], 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 (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 (t==PT_PHOT)
|
||||
{
|
||||
|
Reference in New Issue
Block a user