]> _ Git - aichan-platformer.git/commitdiff
fuck this. this is stupid im going to look up the official example for text wrapping...
authorparking_turkeys <roya1060wien@gmail.com>
Fri, 17 Jul 2026 18:04:44 +0000 (14:04 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Fri, 17 Jul 2026 18:04:44 +0000 (14:04 -0400)
level.c

diff --git a/level.c b/level.c
index 15f2639..0600682 100644 (file)
--- a/level.c
+++ b/level.c
@@ -124,34 +124,22 @@ int drawcharimage(char *filename)
        
 };
 
+
+static char *get_next_word(char *s, int *i);
+
 int drawdialogueline(char *l)
 {
        //DLGTEXTWIDTH (i always forget how to type this)
-       
-       //gay
+       //ok im going to try doing this letter by letter :)
+       int x = CHARADISPLAYWIDTH + DLGPADDING;
+       int y = DLGY + DLGPADDING * 2;
+       char *w;
        int i = 0;
-       char t = l[40];
-       int x = 40;
-       int z = 0;
-       int y = CHARADISPLAYWIDTH + DLGPADDING;
-       int done = 0;
-
-       while (done != 1) {
-               if (MeasureText(l+z, 20) <= DLGTEXTWIDTH) {
-                       DrawText(l, y, DLGY + DLGPADDING * 2 ,20, BLACK);
-                       y += 22;
-                       z =   x;
-                       l[x] = t;
-                       x += 30;
-               
-               } else {
-                       x -= 10;
-                       t = l[x];
-                       l[x] = '\0';
-               };
-                       
-       
-       }
+
+       while ((w = get_next_word(l+i, &i)) != "\0") {
+               printf("%d", i);
+       };
+
        //DrawText(l, CHARADISPLAYWIDTH + DLGPADDING, DLGY + DLGPADDING * 2 ,20, BLACK); //add text wrapping later
 };
 
@@ -160,3 +148,25 @@ int cleanup_level(void)
        UnloadTexture(txtr);
        return 1;
 }
+
+
+char *get_next_word(char *s, int *i)
+{
+       char c;
+       char *w = "";
+       int n = 0;
+
+       while ((c = s[*i]) != ' ') {
+               //printf(&c);
+               w[n] = c; //printf("char added to word");
+               n++;
+               *i += 1;
+               if (c == '\0') {return w;};
+       };
+       w[n] = '\0';
+       return w;
+}
+
+
+
+