summaryrefslogtreecommitdiff
path: root/src/graphics.c
diff options
context:
space:
mode:
authorPhilip <philip@philip-linuxlaptop.(none)>2010-11-11 00:42:42 (GMT)
committer Philip <philip@philip-linuxlaptop.(none)>2010-11-11 00:42:42 (GMT)
commit179a9f731a251249237d9007038771036ff701df (patch)
tree0c0bbce8ed5d8d47c369c28931f4c8230dbd1d06 /src/graphics.c
parent673eb2437e2cc7491b94f95e0f65cd276e351872 (diff)
downloadpowder-179a9f731a251249237d9007038771036ff701df.zip
powder-179a9f731a251249237d9007038771036ff701df.tar.gz
Updating with all new changes
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 2eb1c7a..c56d067 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1002,18 +1002,25 @@ int textnwidth(char *s, int n)
}
return x-1;
}
-int textnheight(char *s, int n, int w)
+void textnpos(char *s, int n, int w, int *cx, int *cy)
{
int x = 0;
+ int y = 0;
//TODO: Implement Textnheight for wrapped text
for(; *s; s++)
{
- if(!n)
+ if(!n){
break;
+ }
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if(x>=w) {
+ x = 0;
+ y += FONT_H+2;
+ }
n--;
}
- return x-1;
+ *cx = x-1;
+ *cy = y;
}
int textwidthx(char *s, int w)
@@ -1029,6 +1036,23 @@ int textwidthx(char *s, int w)
}
return n;
}
+int textposxy(char *s, int width, int w, int h)
+{
+ int x=0,y=0,n=0,cw;
+ for(; *s; s++)
+ {
+ cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
+ if(x+(cw/2) >= w && y+6 >= h)
+ break;
+ x += cw;
+ if(x>=width) {
+ x = 0;
+ y += FONT_H+2;
+ }
+ n++;
+ }
+ return n;
+}
#if defined(WIN32) && !defined(__GNUC__)
_inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a)
@@ -1244,7 +1268,6 @@ void draw_parts(pixel *vid)
int cr, cg, cb;
float fr, fg, fb;
float pt = R_TEMP;
- int gol[XRES][YRES];
for(i = 0; i<NPART; i++) {
#ifdef OpenGL
if(cmode == 6) //If fire mode
@@ -1559,7 +1582,8 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
}
}
- else if(t==PT_SWCH && parts[i].life == 10)
+ //Life can be 11 too, so don't just check for 10
+ else if(t==PT_SWCH && parts[i].life >= 10)
{
x = nx;
y = ny;