initial
authorTobias Gläßer <tobi.web@gmx.de>
Sun, 1 Feb 2004 22:28:19 +0000 (22:28 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Sun, 1 Feb 2004 22:28:19 +0000 (22:28 +0000)
SVN-Revision: 107

data/images/background/arctis.png [new file with mode: 0644]
data/images/highscore/highscore.png [new file with mode: 0644]
data/images/highscore/highscore.xcf [new file with mode: 0644]
src/text.c [new file with mode: 0644]
src/text.h [new file with mode: 0644]

diff --git a/data/images/background/arctis.png b/data/images/background/arctis.png
new file mode 100644 (file)
index 0000000..c5cac49
Binary files /dev/null and b/data/images/background/arctis.png differ
diff --git a/data/images/highscore/highscore.png b/data/images/highscore/highscore.png
new file mode 100644 (file)
index 0000000..d08f055
Binary files /dev/null and b/data/images/highscore/highscore.png differ
diff --git a/data/images/highscore/highscore.xcf b/data/images/highscore/highscore.xcf
new file mode 100644 (file)
index 0000000..d8ef931
Binary files /dev/null and b/data/images/highscore/highscore.xcf differ
diff --git a/src/text.c b/src/text.c
new file mode 100644 (file)
index 0000000..6a31ed7
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// C Implementation: text
+//
+// Description:
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <string.h>
+#include "globals.h"
+#include "defines.h"
+#include "screen.h"
+#include "text.h"
+
+void text_load(text_type* ptext, char* file)
+{
+  int x, y, c;
+
+  c = 0;
+
+  for(y = 0; y < 3 ; ++y)
+    {
+      for(x = 0; x < 26 ; ++x)
+        {
+          texture_load_part(&ptext->chars[c],file,x*16,y*16,16,16, USE_ALPHA);
+          ++c;
+        }
+    }
+}
+
+void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update)
+{
+
+if(shadowsize != 0)
+text_draw(&black_text,text,x+shadowsize,y+shadowsize, 0, update);
+
+  int len = strlen(text);
+  int i;
+  for( i = 0; i < len; ++i)
+    {
+      if( text[i] >= 'A' && text[i] <= 'Z')
+      {
+        texture_draw(&ptext->chars[(int)(text[i] - 'A')],x+i*16,y,update);
+       }
+      else if( text[i] >= 'a' && text[i] <= 'z')
+      {
+        texture_draw(&ptext->chars[(int)(text[i] - 'a') + 26],x+i*16,y,update);
+       }
+      else if ( text[i] >= '!' && text[i] <= '9')
+       {
+       texture_draw(&ptext->chars[(int)(text[i] - '!') + 52],x+i*16,y,update);
+       }
+      else if ( text[i] == '?')
+       {
+       texture_draw(&ptext->chars[77],x+i*16,y,update);
+       }
+      else if ( text[i] == '\n')
+       {
+       y += 18;
+       }
+    }
+}
+
+void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update)
+{
+if(halign == A_RIGHT)
+x += screen->w;
+else if(halign == A_HMIDDLE)
+x += screen->w/2 - ((strlen(text)*16)/2);
+
+if(valign == A_BOTTOM)
+y += screen->h - 16;
+else if(valign == A_VMIDDLE)
+y += screen->h/2;
+
+text_draw(ptext,text,x,y,shadowsize,update);
+
+}
+
+void text_free(text_type* ptext)
+{
+  int c;
+  for( c = 0; c < 78; ++c)
+    texture_free(&ptext->chars[c]);
+}
diff --git a/src/text.h b/src/text.h
new file mode 100644 (file)
index 0000000..a395f11
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// C Interface: text
+//
+// Description: 
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef SUPERTUX_TEXT_H
+#define SUPERTUX_TEXT_H
+
+#include "texture.h"
+
+/* Text type */
+typedef struct text_type
+  {
+   texture_type chars[78];
+  }  
+text_type;
+
+enum {
+   A_LEFT,
+   A_HMIDDLE,
+   A_RIGHT,
+   A_TOP,
+   A_VMIDDLE,
+   A_BOTTOM,
+   A_NONE
+};
+
+void text_load(text_type* ptext, char* file);
+void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update);
+void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update);
+void text_free(text_type* ptext);
+
+#endif /*SUPERTUX_TEXT_H*/
+